Selenium:远程运行我的机器上的测试?

时间:2015-06-29 18:54:51

标签: python selenium selenium-chromedriver remotewebdriver

所以我在我的电脑上运行Chromedriver(胜利,管理员模式),如

chromedriver.exe --verbose --whitelisted-ips=

在我的服务器上,我有我想在自己的计算机上运行的测试。

所以我设置了远程Webdriver,测试似乎没有问题,但我没有看到Chromedriver在我的计算机上生成的任何Chrome窗口,也没有看到任何日志消息。我服务器上的测试最终超时并显示:

 File "/server/tests/test.py", line 173, in test
    browser = Browser(driver_name="remote",url="http://23.23.23.23:9515/wd/hub", browser='chrome',user_agent='test', desired_capabilities=options.to_capabilities())
  File "/usr/local/lib/python2.7/dist-packages/splinter/browser.py", line 63, in Browser
    return driver(*args, **kwargs)
  File "/usr/local/lib/python2.7/dist-packages/splinter/driver/webdriver/remote.py", line 26, in __init__
    self.driver = Remote(url, abilities)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 73, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 121, in start_session
    'desiredCapabilities': desired_capabilities,
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/webdriver.py", line 171, in execute
    response = self.command_executor.execute(driver_command, params)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 349, in execute
    return self._request(command_info[0], url, body=data)
  File "/usr/local/lib/python2.7/dist-packages/selenium/webdriver/remote/remote_connection.py", line 417, in _request
    resp = opener.open(request)
  File "/usr/lib/python2.7/urllib2.py", line 400, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 418, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 378, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1207, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1177, in do_open
    raise URLError(err)
URLError: <urlopen error [Errno 110] Connection timed out>

1 个答案:

答案 0 :(得分:2)

解决方案:使用selenium grid,它也可以这样工作。