tl / dr:我在做什么错?
我正在尝试在本地运行硒测试,并与Browserstack平台兼容。我使用以下代码在本地连接:
wd = webdriver.Remote('http://[email protected]:80/wd/hub', {'browser':'firefox'})
wd.get('http://google.com')
wd.get_screenshot_as_file('/tmp/googl.png')
wd.close()
我在中看到了一个不错的屏幕截图/tmp/
。
现在,我尝试对本地Selenium执行相同操作:
$ java -jar /usr/share/java/selenium-server-standalone-2.44.0.jar &
服务器正常启动。我尝试使用Firefox(30.0)创建会话,它可以正常工作。(默认浏览器是Opera。)
然后,我尝试运行Python代码:
wd = webdriver.Remote('http://localhost:4444/wd/hub', {'browser':'firefox'})
wd.get('http://google.com')
wd.get_screenshot_as_file('/tmp/googl2.png')
wd.close()
Selenium打开Opera而不是Firefox。
我在Python控制台中看到了这一点:
Message: <html>
<head>
<title>Error 500 org/json/JSONObject</title>
</head>
<body>
<h2>HTTP ERROR: 500</h2><pre>org/json/JSONObject</pre>
<p>RequestURI=/wd/hub/session</p>
<p><i><small><a href="http://jetty.mortbay.org">Powered by Jetty://</a></small></i></p>
为什么它打开Opera而不是Firefox?
问题在这一行:
wd = webdriver.Remote('http://localhost:4444/wd/hub', {'browser':'firefox'})
更改browser
为browserName
可以修复它。使用
wd = webdriver.Remote('http://localhost:4444/wd/hub', {'browserName':'firefox'})
反而。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句