gpt4 book ai didi

python - Selenium 网格监听节点端口而不是集线器端口

转载 作者:太空宇宙 更新时间:2023-11-03 14:42:15 24 4
gpt4 key购买 nike

对于我的测试,我在不同的端口上本地运行网格和节点。

java -jar /usr/bin/selenium-server.jar -port 4444 -role hub
java -jar /usr/bin/selenium-server.jar -role node -hub http://127.0.0.1:4444/grid/register -port 5556

因此,网格运行在 4444 上,节点运行在 5556 上。

在我的测试中,如果我启动驱动程序

driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=desired_capabilities)

然后测试失败并出现异常

response = {'status': 500, 'value': '{"status":13,"value":{"class":"java.lang.NullPointerException","stackTrace":[{"fileName":"Ha...n","lineNumber":590},{"fileName":"Thread.java","className":"java.lang.Thread","methodName":"run","lineNumber":745}]}}'}

如果我在节点端口 5555 而不是集线器端口 4444 上运行测试,则测试通过,如下所示

driver = webdriver.Remote(command_executor='http://127.0.0.1:5555/wd/hub', desired_capabilities=desired_capabilities)

我认为,我们应该在集线器端口上运行测试,在本例中是 4444 而不是 5555。

如有错误,请指正。

最佳答案

如果您打算使用Selenium Grid 通过 Hub 配置 Node 配置,我建议您使用最新的 selenium-server-standalone-3.6.0 jar 如下:

  1. 启动Selenium Grid Hub (默认在端口 4444 上):

    java -jar selenium-server-standalone-3.6.0.jar -role hub
  2. 确认Selenium Grid Hub 已启动:

    16:06:29.891 INFO - Nodes should register to http://192.168.1.48:4444/grid/register/
    16:06:29.891 INFO - Selenium Grid hub is up and running
  3. 访问Selenium Grid Hub Console 并确保 Selenium Grid Hub 已启动并运行:

    http://localhost:4444/grid/console
  4. 启动Selenium Grid Node (默认在端口 5555)Mozilla/GeckoDriver:

    java -Dwebdriver.gecko.driver=geckodriver.exe -jar selenium-server-standalone-3.6.0.jar -role node -hub http://localhost:4444/grid/register
  5. 确认Selenium Grid Node 已注册并启动:

    16:15:54.696 INFO - Selenium Grid node is up and ready to register to the hub
    16:15:54.742 INFO - Starting auto registration thread. Will try to register every 5000 ms.
    16:15:54.742 INFO - Registering the node to the hub: http://localhost:4444/grid/register
    16:15:54.975 INFO - The node is registered to the hub and ready to use
  6. 使用 Testcase 执行 DesiredCapabilities 如下:

    self.driver = webdriver.Remote(command_executor='http://127.0.0.1:4444/wd/hub', desired_capabilities=caps)
  7. 在成功执行 Testcase 时,观察以以下内容结尾的控制台日志。 :

    16:23:50.590 INFO - Found handler: org.openqa.selenium.remote.server.ServicedSession@37ff9771
    16:23:50.590 INFO - Handler thread for session 31a1dcb0-8bed-40fb-acdb-d5be19f03ba2 (firefox): Executing DELETE on /session/31a1dcb0-8bed-40fb-acdb-d5be19f03ba2
    (handler: ServicedSession)
    1506941630595 Marionette INFO New connections will no longer be accepted

关于python - Selenium 网格监听节点端口而不是集线器端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46496191/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com