tl/dr: What am I doing wrong?
I'm trying to run selenium tests locally and be compatible with Browserstack platform. I use this code to connect locally:
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()
I see a good screenshot in /tmp/.
Now I try to do the same with local Selenium:
$ java -jar /usr/share/java/selenium-server-standalone-2.44.0.jar &
The server starts nominally. I try creating a session with Firefox (30.0), it works correctly. (Default browser is Opera.)
Then I try to run Python code:
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 opens Opera instead of Firefox.

I see this in Python console:
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>
Why does it open Opera instead of Firefox?
The problem is in this line:
wd = webdriver.Remote('http://localhost:4444/wd/hub', {'browser':'firefox'})
Changing browser to browserName will fix it. Use
wd = webdriver.Remote('http://localhost:4444/wd/hub', {'browserName':'firefox'})
instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With