Tuesday, February 14, 2017

Java Phantomjs behaving different in windows and linux

Leave a Comment

I been trying to solve this issue but not sure what's the cause for this, i made a program with java and phantomjs, and in theory they both should behave the same way.

Phantomjs in both the pc and the server is the same v.2.0.

In windows(v.7) mi testing program works as expected, but in linux (debian) the program fails, with this error when it tries to click an element:

Caused by: org.openqa.selenium.NoSuchElementException: {"errorMessage":"Unable to find element with css selector 

Now, i know sometimes we have to wait for few seconds for the page to load, which already do (even added a few more just to be sure) and it was tested correctly in windows.

i tried with the click function:

 element.click(); 

with a javascript code:

 JavascriptExecutor js = (JavascriptExecutor)driver;     js = (JavascriptExecutor)driver;     js.executeScript("arguments[0].click();", element) 

and with actions too:

Actions action = new Actions(driver); action.moveToElement(element).contextClick().build().perform();      //and this code too action.moveToElement(element).click().build().perform(); 

Anyone had this same or similar issue? what i else i can do? i'm stuck since yesterday and i wan't able to figure out this problem.

note: for now i have an alternate way to get page without having interaction, but still having different results from the web page when executing in different OS, for example:

where i normally i get this link: www.somesite.com/?search=xxxxx&date_in=dd/MM/yyyy&params=etc. , instead i get www.somesite.com/?search=xxxxx, the default search without any especific search parameters.

1 Answers

Answers 1

You need to use onResourceError callback, to find out what's going wrong.
You also need to use the following Command-Line options:

--ignore-ssl-errors=true --ssl-protocol=any --debug=true 

See also: this issue.

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment