selenium RC+JAVA 运行所遇到的问题

来源:互联网 发布:淘宝开企业店铺多少钱 编辑:程序博客网 时间:2024/06/10 17:50

1.报错一

Failed to start new browser session: java.lang.RuntimeException: Firefox 3 could not be found in the path!
Please add the directory containing ''firefox.exe'' to your PATH environment.

原因:

  firefox没有安装在c盘(本人安装在d盘下),selenium找不到firefox路径。
解决过程:首先尝试将firefox.exe的路径放到系统环境变量path中,重新运行,错误依旧。
正确解决办法:在调用firefox处加上绝对路径(selenium("localhost", 4444, "*firefox D:\\Program Files\\Mozilla Firefox\\firefox.exe", "http://www.baidu.com"))



2.报错二

java.lang.RuntimeException: Could not contact Selenium Server; have you started it on 'localhost:4444' ?

原因:selenium server未启动
解决方案:启动selenium server:java -jar selenium-server-standalone-2.24.1.jar


2.报错三

Firefox 无法在 chrome://src/content/RemoteRunner.html?sessionId=e4a9ff6710024147858b77bf8c3b7e6c&multiWindow=true&baseUrl=https://www.google.com.hk/&debugMode=false&driverUrl=http://localhost:4444/selenium-server/driver/ 找到该文件。


原因:

  Firefox版本与selenium server版本不一致导致的。

  百度了下,原来是selenium的版本和firefox不兼容,需要升级selenium或者firefox。

  【Selenium】   -> 【FireFox】

  2.25.0        ->  18

  2.30.0        ->  19

  2.31.0        ->  20

  2.42.2        ->  29

  2.44.0        ->  33 (不支持31,2014/12/1) 升级selenium jar包,或者是升级firefox。

   PS:但是selenium-java-2.42.2版本和firefox 29.0.1版本兼容,如果升级到firefox 30+,则浏览器启动失败。可能是selenium还未同步升级,后面估计可以正常支持。切记,关掉forefox的升级功能,否则连本地Windows上的脚本都跑不起来,作者曾经为此还降级了forefox。 升级后,selenium脚本正常启动firefox。


注意:火狐版本经常会自动更新,记得将自动更新的勾选去掉,火狐:选项-高级-更新:不检查更新


0 0
原创粉丝点击