代码之家  ›  专栏  ›  技术社区  ›  Anil Jagtap

WebDriverException:转发新会话时出错转发连接到my\u ip的请求时出错:5555[/my\u ip]失败:连接超时

  •  1
  • Anil Jagtap  · 技术社区  · 6 年前

    我在AWS windows上安装并启动了selenium节点。我在AWS Linux上安装了Jenkins、git、Seleniuim hub。当我在Jenkins上构建应用程序时,selenium hub正在尝试使用连接到AWS windows的selenium节点 专用IP地址 . 我得到以下例外:

    org.openqa.selenium.WebDriverException: 
    Error forwarding the new session Error forwarding the request Connect to windows_private_ip:5555 [/windows_private_ip] failed: Connection timed out (Connection timed out)
    Command duration or timeout: 190.25 seconds
    Build info: version: '3.5.1', revision: '9c21bb67ef', time: '2017-08-17T15:26:08.955Z'
    System info: host: 'some_host_name', ip: 'some_ip', os.name: 'Linux', os.arch: 'amd64', os.version: '4.9.76-3.78.amzn1.x86_64', java.version: '1.8.0_151'
    Driver info: driver.version: RemoteWebDriver
    Caused by: org.openqa.grid.common.exception.GridException: Error forwarding the new session Error forwarding the request Connect to windows_private_ip:5555 [/windows_private_ip] failed: Connection timed out (Connection timed out)
    

    网格节点命令:

    C:\Users\Administrator>java -Dwebdriver.chrome.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
    

    我的代码是:

    if (browser.equalsIgnoreCase("FF")) {
                System.setProperty("webdriver.gecko.driver", "drivers/windows-driver/geckodriver.exe");
                DesiredCapabilities cap = DesiredCapabilities.firefox();
                // Set the platform where we want to run our test- we can use
                // MAC and Linux and other platforms as well
                cap.setPlatform(Platform.ANY);
                cap.setCapability("gecko", true);
                // Here you can use hub address, hub will take the
                // responsibility to execute the test on respective node
                URL url = new URL("http://hub_public_ip:4444/wd/hub");
                // Create driver with hub address and capability
                gbb = PageFactory.initElements(new RemoteWebDriver(url, cap), GuruBase.class);
            } else if (browser.equalsIgnoreCase("IE")) {
                System.setProperty("webdriver.ie.driver", "drivers/windows-driver/IEDriverServer.exe");
                gbb = PageFactory.initElements(new InternetExplorerDriver(), GuruBase.class);
    
            } else if (browser.equalsIgnoreCase("GC")) {
                System.setProperty("webdriver.chrome.driver", "drivers/windows-driver/chromedriver.exe");
                ChromeOptions cho = new ChromeOptions();
                cho.addArguments("disabled-extensions");
                cho.addArguments("--start-maximized");
                gbb = PageFactory.initElements(new ChromeDriver(cho), GuruBase.class);
            }
    
            else if (browser.equalsIgnoreCase("html")) {
                gbb = PageFactory.initElements(new HtmlUnitDriver(true), GuruBase.class);
            }
    

    我在Jenkins上运行selenium中心。

    3 回复  |  直到 6 年前
        1
  •  1
  •   undetected Selenium    6 年前

    快速解决方案是改变:

    java -Dwebdriver.gecko.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
    

    当您使用时 Dwebdriver。壁虎。驾驶员 具有 chromedriver。exe文件

    收件人:

    • 使用 壁虎河 :

      java -Dwebdriver.gecko.driver=./drivers/windows-driver/geckodriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
      
    • 使用 镀铬驱动器 :

      java -Dwebdriver.chrome.driver=./drivers/windows-driver/chromedriver.exe -jar C:\\Users\\Administrator\\Desktop\\selenium-server-standalone-3.0.1.jar -role node -hub http://ip_address:4444/grid/register
      

    此外,您需要检查您的 if() 循环,因为您对 窗户 Linux操作系统 中的样式 System.setProperty() 行如下:

    • 壁虎河 :

      System.setProperty("webdriver.gecko.driver", "drivers/windows-driver/geckodriver.exe");
      
    • 镀铬驱动器 :

      System.setProperty("webdriver.chrome.driver", "drivers/windows-driver/chromedriver");
      
    • IEDriversServer :

      System.setProperty("webdriver.ie.driver", "drivers/windows-driver/IEDriverServer.exe");
      

    笔记 :打开 Windows系统 你需要提到分机 .exe文件 零件,例如。 壁虎河。exe文件 打开时 Linux系统 你需要把分机拆掉 .exe文件 零件,例如。 镀铬驱动器

        2
  •  1
  •   Kai    6 年前

    这可能是由于您的ip不匹配造成的。我遇到了相同的错误,我发现我的机器有两个IPv4地址。一个是Eather net,另一个是WLAN。 步骤:

    • 断开Wi-Fi连接。
    • 使用命令: ipconfig 检查我的IPv4地址(那里只有一个IP)。
    • 仅使用一个IP,它应正确创建会话。
        3
  •  0
  •   Kalyan .P    6 年前

    也许您正在使用office计算机在节点和中心之间进行事务处理。

    在某种程度上,您可以从office computer推送代码<=&燃气轮机;github<=&燃气轮机;AWS EC2控制台。 但是将其注册为节点/集线器并尝试执行测试用例可能是不可能的。

    请在同一环境中尝试使用服务器。