关于通过Selenium和Python调用webdriver.Remote(“http:// localhost:4444 / wd / hub”,webdriver.DesiredCapabilities.CHROME)的WebDriverException

问题描述 投票:1回答:1

我很确定这将是一个头脑,但我已经跟随了我能找到的一些文档,我无法摆脱这个错误。我正在设置Selenium Grid(在Docker中)并且只有在我没有指定遥控器时才能运行测试。这是代码

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

FWIW,这工作正常,但在没有command_executor的网格环境中没用:

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

基于许多来源,包括https://hackr.io/blog/complete-guide-selenium-webdriver,对RemoteWebDriver的调用应该是正确的。

这是错误:

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
python selenium docker selenium-webdriver selenium-grid
1个回答
1
投票

此错误消息...

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

...表示客户端程序无法启动新的WebBrowsing会话,即Chrome浏览器会话。

您的主要问题是Selenium Grid Hub和Selenium Grid Node之间的连接。


确保以下内容:

  • Selenium Grid Hub已成功启动。
  • Selenium网格节点在Selenium Grid Hub中成功启动和配置
© www.soinside.com 2019 - 2024. All rights reserved.