Selenium网格路由到错误的节点

时间:2017-02-04 17:40:02

标签: python selenium selenium-grid

我的selenium grid 3.0.1设置有一个集线器和三个节点,如下所示:

  • 第一个节点:使用Chrome和Firefox的Linux
  • 第二个节点:带有Chrome,Firefox,Edge和Internet Explorer的Windows 10
  • 第三个节点:使用Android模拟器运行Appium的Linux

由于某种原因,网格不会根据平台和浏览器智能地选择节点。

我特别关注IE和Appium。

我用以下方式启动集线器:

nohup java -cp selenium-video-node-2.1.jar:selenium-server-standalone-3.0.1.jar org.openqa.grid.selenium.GridLauncherV3 \
 -servlets com.aimmac23.hub.servlet.HubVideoDownloadServlet \
 -role hub \
 2>&1 > logs/hub.log &

我启动我的linux节点,例如:

nohup java -Dwebdriver.chrome.driver="/home/ubuntu/testcloud/webdrivers/chromedriver" \
       -Dwebdriver.chrome.bin="/usr/bin/opera" \
       -Dwebdriver.chrome.logfile="/home/ubuntu/testcloud/logs/chrome.log" \
       -Dwebdriver.gecko.driver="/home/ubuntu/testcloud/webdrivers/geckodriver" \
       -Dwebdriver.firefox.bin="/home/ubuntu/testcloud/browsers/firefox/firefox" \
       -Dwebdriver.firefox.logfile="/home/ubuntu/testcloud/logs/firefox.log" \
       -cp selenium-video-node-2.1.jar:selenium-server-standalone-3.0.1.jar org.openqa.grid.selenium.GridLauncherV3 \
       -servlets com.aimmac23.node.servlet.VideoRecordingControlServlet -proxy com.aimmac23.hub.proxy.VideoProxy \
       -role wd -hub "http://172.31.1.65:4444/grid/register/" \
  2>&1 > logs/selenium.log &

我使用以下命令在python中配置驱动程序:

d=DesiredCapabilities.INTERNETEXPLORER.copy()
d['loggingPrefs']={ 'browser': 'ALL' }
d["platform"]="WINDOWS"
driver = webdriver.Remote(
    command_executor="http://"+HUB+":4444/wd/hub",
    desired_capabilities=d
)
driver.maximize_window()
driver.implicitly_wait(30)

当我使用此配置运行测试时,每3次中有2次,其他节点会响应以下内容:

    Traceback (most recent call last):
  File "test_appium.py", line 15, in <module>
    driver = webdriver.Remote('http://35.154.75.140:4444/wd/hub', desired_caps)
  File "/home/ubuntu/.photon/local/lib/python2.7/site-packages/appium/webdriver/webdriver.py", line 36, in __init__
    super(WebDriver, self).__init__(command_executor, desired_capabilities, browser_profile, proxy, keep_alive)
  File "/home/ubuntu/.photon/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 92, in __init__
    self.start_session(desired_capabilities, browser_profile)
  File "/home/ubuntu/.photon/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 179, in start_session
    response = self.execute(Command.NEW_SESSION, capabilities)
  File "/home/ubuntu/.photon/local/lib/python2.7/site-packages/selenium/webdriver/remote/webdriver.py", line 236, in execute
    self.error_handler.check_response(response)
  File "/home/ubuntu/.photon/local/lib/python2.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 192, in check_response
    raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.WebDriverException: Message: The best matching driver provider Firefox/Marionette driver can't create a new driver instance for Capabilities [{app=https://transfer.sh/T20EJ/iifl.apk, platformVersion=4.4.2, platformName=Android, deviceName=Android 19}]
Build info: version: '3.0.1', revision: '1969d75', time: '2016-10-18 09:48:19 -0700'
System info: host: 'ip-172-31-12-96', ip: '172.31.12.96', os.name: 'Linux', os.arch: 'amd64', os.version: '4.4.0-53-generic', java.version: '1.8.0_111'
Driver info: driver.version: unknown
Stacktrace:
    at org.openqa.selenium.remote.server.DefaultDriverFactory.newInstance (DefaultDriverFactory.java:62)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:222)
    at org.openqa.selenium.remote.server.DefaultSession$BrowserCreator.call (DefaultSession.java:209)
    at java.util.concurrent.FutureTask.run (FutureTask.java:266)
    at org.openqa.selenium.remote.server.DefaultSession$1.run (DefaultSession.java:176)
    at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)

有人可以帮我解决这个问题吗?

1 个答案:

答案 0 :(得分:0)

发现问题。

我希望Selenium Grid能够自动检测平台和浏览器并相应地进行路由。

看起来并非如此,您需要定义一个JSON节点配置,该配置指定匹配的功能。一个很好的例子是here

相关问题