Getting a 404 on /wd/hub/session when I try to connect to selenium grid remotely via Python
Asked Answered
B

2

9

I can see two remotes under the console but when I try to connect remotely and execute something it fails with a 404.

from selenium import webdriver
browser = webdriver.Remote(
   command_executor='http://ec2-184-72-129-183.compute-1.amazonaws.com:4444/wd/hub',
   desired_capabilities={'browserName': 'firefox'})
browser.get('http://www.google.com')
browser.quit()

Throws this exception

Traceback (most recent call last):
  File "browser-shot.py", line 16, in <module>
    desired_capabilities={'browserName': 'firefox'})
  File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 62, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 104, in start_session
    'desiredCapabilities': desired_capabilities,
  File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/webdriver.py", line 155, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.6/dist-packages/selenium/webdriver/remote/errorhandler.py", line 125, in check_response
    raise exception_class(value)
selenium.common.exceptions.WebDriverException: Message: '<html>\n<head>\n<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>\n<title>Error 404 </title>\n</head>\n<body><h2>HTTP ERROR: 404</h2><pre>NOT_FOUND</pre>\n<p>RequestURI=/wd/hub/session</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a></small></i></p><br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n<br/>                                                \n\n</body>\n</html>\n' 
Blueberry answered 26/6, 2012 at 13:11 Comment(3)
I have a similar problem. It seems either /wd/hub/session isn't being served by selenium or the Remote is looking for a resource in the wrong place.Structural
Its a shot in the dark, since i'm not familiar with Python bindings, but this could be connection related, i have several problems where i could connect to the grid via IDE but wasn't possible on Hudson/Jenkins.Oilbird
I recomend you to remove the aws url from the example... you know, just in case :)Phreno
M
2

This doesn't appear to be a python error. It seems like the machine you have your selenium server on is refusing requests. In the error message, you have an <a href="http://jetty.mortbay.org/">Powered by Jetty://</a> which got me thinking that it is somehow related to Jetty.

I don't know much about Jetty, but you might want to look there for your answers. One possible problem is that Jetty is also running on port 4444, but I can't say for sure, because I don't know how Jetty works.

EDIT

I should also add that I tried your setup on my local machine, to one of my servers (that doesn't have Jetty on it) and it worked perfectly fine.

Manzanares answered 16/1, 2013 at 18:50 Comment(6)
I think Jetty is the webserver that selenium grid runs on top of. If Jetty were running as a separate process there, wouldn't either Jetty or the grid throw a binding error when starting, saying the port is in use?Structural
Wait, are you using the standalone server for selenium?Manzanares
Also, can you post your selenium version?Manzanares
I'm using selenium grid 1.0.8. I'm starting the grid with ant launch-hubStructural
Could you try to use the standalone server that is here: selenium.googlecode.com/files/…Manzanares
that was it. "I'll change this to use a port that nobody uses ... like 4444." oops.Gaius
P
1

Try running selenium hub using_

-port 5555

And then configure clients with also:

-port 5555

I think is an issue with another software using port 4444 or selenium is not starting in that port correctly.

Phreno answered 16/1, 2013 at 20:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.