添加链接
link之家
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

WebDriverException on invoking webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.CHROME) through Selenium and Python

Ask Question

I'm pretty sure this'll be a head smacker, but I've followed ever bit of doc I can find and I can't get rid of this error. I'm in the process of setting up a Selenium Grid (in Docker) and can get tests to run only if I don't specify the remote. Here's the code

def setUp(self):
    self.browser = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.CHROME)

FWIW, this works fine, but isn't useful in a grid environment without the command_executor:

def setUp(self):
    self.browser = webdriver.Chrome()

Based on a number of sources, including https://hackr.io/blog/complete-guide-selenium-webdriver, the call to the RemoteWebDriver should be correct.

Here's the error:

ERROR: test_hackernews_search_for_selenium (__main__.HackerNewsSearchTest)
Traceback (most recent call last):
  File "test.py", line 16, in setUp
    self.browser = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.CHROME)
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 157, in __init__
    self.start_session(capabilities, browser_profile)
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 252, in start_session
    response = self.execute(Command.NEW_SESSION, parameters)
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
    self.error_handler.check_response(response)
  File "/usr/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
    raise exception_class(message, screen, stacktrace)
WebDriverException: Message: None
                Thanks for responding.  I'm not completely sure what the difference was, but I found if I created the nodes with docker-compose, everything sorted itself out.
– reknab
                Apr 30, 2019 at 12:13

This error message...

ERROR: test_hackernews_search_for_selenium (__main__.HackerNewsSearchTest)
Traceback (most recent call last):
  File "test.py", line 16, in setUp
    self.browser = webdriver.Remote("http://localhost:4444/wd/hub", webdriver.DesiredCapabilities.CHROME)
WebDriverException: Message: None

...implies that the client program was unable to initiate a new WebBrowsing Session i.e. Chrome Browser session.

Your main issue is the connectivity between the Selenium Grid Hub and Selenium Grid Node.

Solution

Ensure the following:

  • The Selenium Grid Hub is initiated successfully.
  • The Selenium Grid Node is initiated and provisioned successfully within the Selenium Grid Hub
  • I suspect you're probably correct. I set up the grid by hand first. I think that docker-compose eliminated any mistake I might have made. – reknab Apr 30, 2019 at 19:05

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.