简体   繁体   English

Java Phantomjs在windows和linux中表现不同

[英]Java Phantomjs behaving different in windows and linux

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. 我一直试图解决这个问题,但不知道是什么原因造成的,我用java和phantomjs制作了一个程序,理论上它们的行为应该是一样的。

Phantomjs in both the pc and the server is the same v.2.0. pc和服务器中的Phantomjs是相同的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: 在Windows(v.7)中,mi测试程序按预期工作,但在linux(debian)中,程序失败,当它尝试单击一个元素时出现此错误:

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. 现在,我知道有时我们必须等待几秒钟来加载页面,这已经做了(甚至还添加了一些以确保)并且它已在Windows中正确测试。

i tried with the click function: 我试过点击功能:

 element.click();

with a javascript code: 使用javascript代码:

 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. 我通常在这里获得这个链接: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. 相反,我得到www.somesite.com/?search=xxxxx,默认搜索没有任何特定的搜索参数。

You need to use onResourceError callback, to find out what's going wrong. 您需要使用onResourceError回调,以找出出错的地方。
You also need to use the following Command-Line options: 您还需要使用以下命令行选项:

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

See also: this issue . 另请参阅: 此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Java FileInputStream 在 Windows 和 Linux 中表现出不同的行为 - Java FileInputStream exhibits different behaviour in Windows and Linux Java字符串编码-Linux与Windows不同 - Java String encoding - Linux different than on Windows 为什么Windows和Linux上的字体呈现方式不同(java) - Why font rendering is different on Windows and Linux (java) Java 对继承方法的反射在 Windows 和 Linux 中是否不同? - Is Java Reflection on Inherited Methods Different in Windows and Linux? Java JAR文件在不同的操作系统上表现不同 - Java JAR file behaving differently on different OS Java在arm64上的行为方式不同 - Java behaving in a different way on arm64 Java getTimeZone()对于不同类型的输入表现不同 - Java getTimeZone() behaving differently for different kind of inputs Linux和Windows java编译器是否生成相同或不同的类文件? - Do Linux and Windows java compilers produce the same or different class files? Java7 DatagramSocket.setReceiveBufferSize在Windows和Linux之间有什么不同? - Java7 DatagramSocket.setReceiveBufferSize way different between Windows and Linux? Java字符串拆分在Windows和Linux上提供不同的输出 - Java string split gives different outputs on Windows and linux
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM