Getting cell text from a table using Watir on Mac Safari - osx-snow-leopard

I've been pulling my hair out trying to figure out why Safari isn't getting cell text from a table.
It seems like this should be working
require 'rubygems'
require 'safariwatir'
#b = Watir::Safari.new
#b.goto(my_webpage)
cell = #b.table(:class, "user-table")[0][1] #getting row 0 cell 1
puts cell.text
I get the error
/Library/Ruby/Gems/1.8/gems/safariwatir-0.4.0/lib/safariwatir/scripter.rb:189:in `find_cell': uninitialized constant Watir::JavaScripter::MissingWayOfFindingObjectException (NameError)
Chrome works just find.
Totally confused!
Thanks for your help.

If you use Watir-Webdriver gem to drive Chrome and Safari it should take care of your problem.
Safariwatir and Watir-Webdriver have similar a API, but not completely identical, as you have noticed. Safariwatir obviously does not support accessing table cells via [].
See this link for details on getting Safari working with Watir-Webdriver

Related

How to web scraping Highcharts values?

I'm trying to get data from a Highchart, but I only have a "None" value.
The chart needs a password to be accessed, but I have the same problem with the chart on this page.
Using the browser's DevTools I can get the y value from highchart using:
Highcharts.charts[0].series[0].data[0].y
Thus, combining this code with a loop structure I can have all the y values.
The problem is when I try to use Selenium to webscraping those values. I'm using the code below
page.execute_script('Highcharts.charts[0].series[0].data[0].y')
The answer I expect is 2 (as in DevTools), but instead I'm getting "None" as answer.
I already tried to use Beautifulsoup to retrieve the y value from the <path> tag, but it doesn't meet the expected value.
The HTML source seems to be complex (I'm not expert in these area). The full xpath of the <svg> is:
/html/body/form/div[3]/div[2]/div[2]/section/div/div/div[2]/div/section/div/div/div/div[2]/div[2]/div[1]/div[2]/div/div/svg
Also, I can't find any <iframe>, which could be avoiding me from accessing the graph.
Does anyone knows what I'm doing wrong? (I'm beginner in this area, so let me know if any further information is necessary)
After a long time stuck in it, I figured out how to solve this problem.
My mistake is that I was sending to my browser, via selenium, the js script below to be executed.
page.execute_script('Highcharts.charts[0].series[0].data[0].y')
This code is working perfectly but it doesn't return to me any value. So, in order to have the y value (that is what I need), I just need to use a "return" in the previously code. The final code is
page.execute_script('return Highcharts.charts[0].series[0].data[0].y')

AngularJs: Error: A security problem occurred in IE11

We have developed a site using AngularJS 1.2.x version. The data to be displayed is got as a JSON and we have used angular expresions to populate these.
In the JSON response we have a URL in this format http://username#site.com. This is getting rendered properly in Chrome, FF. But in IE11 we are getting the following exception
Error: A security problem occurred.
at xa (site/angularjs.d7ecc107a031818a8e5269a12c25ec8e.js:124:230)
at Anonymous function (site/angularjs.d7ecc107a031818a8e5269a12c25ec8e.js:116:319)
at Anonymous function (site/angularjs.d7ecc107a031818a8e5269a12c25ec8e.js:116:319)
at Anonymous function (site/angularjs.d7ecc107a031818a8e5269a12c25ec8e.js:116:319)
at r (site/angularjs.d7ecc107a031818a8e5269a12c25ec8e.js:7:390)
at start (site/angularjs.d7ecc107a031818a8e5269a12c25ec8e.js:285:470)
at c (site/angularjs.d7ecc107a031818a8e5269a12c25ec8e.js:282:408)
at G (site/angularjs.d7ecc107a031818a8e5269a12c25ec8e.js:284:243)
at Anonymous
We found a similar question in(Angularjs with Internet Explorer 11, security issue) but the link provided in the accepted answer is no longer valid.
Is there any workaround to solve this issue?
I guess it's not possible, it's a security matter of IE and there's no workaround for that other than changing the url format to something IE accepts.
About the broken link, for some reason the english version of that article is not available anymore, but I've switched the locales in the url and managed to find other languages including pt-BR, pt-PT, es-ES and based on your profile hi-IN, if that doesn't work for you, you can try to Google Translate one of them to english or even try different lacale in the article url.
Those are the ones I tried and they're not broken:
Portuguese (Portugal) : pt-PT - https://support.microsoft.com/pt-pt/help/834489
Chinese (China) : zh-cn - https://support.microsoft.com/zh-cn/help/834489
Portuguese (Brazil): pt-BR - https://support.microsoft.com/pt-br/help/834489
Spanish (Spain): es-ES - https://support.microsoft.com/es-es/help/834489
Hindi (India): hi-IN - https://support.microsoft.com/hi-in/help/834489
Japanese (Japan): ja-jp - https://support.microsoft.com/ja-jp/help/834489
There ought to have more locales available but I'm not wiling to test all of them.

Ext Post converts characters in IE11

I noticed that in IE11 and Edge (but not Chrome), Extjs6 is encoding my jsonData in a strange way. If I do a POST with the string '‎8‎/‎17‎/‎2016 13:07:00' as one of the jsonData parameters, it will pass '\u200e8\u200e/\u200e17\u200e/\u200e2016 13:07:00' in the request body.
I also noticed that if I enter Ext.JSON.encode('‎8‎/‎17‎/‎2016 13:07:00') into the console that it converts the string in the same way. I suspect that Extjs is using IE's encoder (since Chrome works), so it is really an IE issue and not an Extjs issue. Can you please explain why this happens and if there is a format that will not convert improperly for my POST?
There is a simple mistake here as far as i think.
Do
Ext.JSON.encode("8/17/2016 13:07:00")
instead of
Ext.JSON.encode('8/17/2016 13:07:00')
then it will take it as the string that you want.
And ya one more thing, this issue will be in latest chrome version also.
Once I discovered the issue is with toLocaleDateString(), then I found this post which answered the question:
ToLocaleDateString() changes in IE11
Instead of Ext.encode(new Date('2016-08-17T06:37:00').toLocaleDateString()), use Ext.encode(new Date('2016-08-17T06:37:00').toLocaleDateString().replace(/\u200E/g, ''))

JfreeChart and ValueMarker not displayed (headless environment)

I have a problem while generating a chart. Every part on the chart is well generated except a ValueMarker which is not. I am working on a web application in a headless RedHat environment. I got another problem for the chart generation (which is now solved), the description of my environment is here :
JFreeChart strange rendering (headless RedHat)
It is working perfectly on Windows.
The piece of code adding the ValueMarker is :
Marker distanceTiers = new ValueMarker(Double.parseDouble(resultDistance.replace(Constants.UNITE_DISTANCE, "")));
distanceTiers.setPaint(Color.BLACK);
plot.addDomainMarker(distanceTiers);
Here is what I obtain, I am supposed to get a vertical line at X = 40 and I cannot figure out why everything except this line is going well :
If someone has an explanation for this, please do not hesitate.
It's not clear where you get the domain value used to construct the ValueMarker, but you might compare your approach to that shown in this Q&A

Backbone.js, IE 8 and Win 7

Just started to work in backbone.js and asp.net. The code is working fine in Firefox and the same code is not working in IE 8. Do I need to config something to make it work in IE 8?
Console.log works only in Firefox, not sure where to see the logged messsage in IE8 (already using the developer tool of IE 8).
Thanks
In IE 8 you can go to the "Script" tab (you'll see it on the left where there's HTML, CSS, Script, and Profiler tabs) and the console is on the right hand side in that tab.
And the answer to your first question is no, there's nothing special for Backbone.js and IE, you probably have some JavaScript that is perfectly standards compliant and of course, IE 8 doesn't like it.
For example, don't end a list with a trailing comma:
{
"something" : "value",
"other" : "different value",
}
would be fine in Firefox, not-so-much in IE.
Good luck.
I ran into this on my last project. Items like the one mentioned by John can be flagged by running your code through jslint. The trailing comma was my biggest offender
You can use http://www.jslint.com/ and cut down on some of the errors and warning that are not related to running in IE.

Resources