首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >WebDriverException:转发新会话时出错,将请求连接转发到my_ip:5555 [/my_ip]失败:连接超时

WebDriverException:转发新会话时出错,将请求连接转发到my_ip:5555 [/my_ip]失败:连接超时
EN

Stack Overflow用户
提问于 2018-02-26 14:41:59
回答 3查看 11.6K关注 0票数 1

我在AWS窗口上安装了selenium节点并启动了它。我在AWS上安装了Jenkins,git,Seleniuim中心。当我在Jenkins上构建应用程序时,selenium试图用私有IP地址连接到AWS窗口的selenium节点。我得到的例外是:

代码语言:javascript
复制
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)

网格节点命令:

代码语言:javascript
复制
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

我的代码是:

代码语言:javascript
复制
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);
        }

我在查詹金斯的硒中心。

EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2018-02-26 15:22:32

一个快速的解决办法是改变:

代码语言:javascript
复制
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.gecko.driverchromedriver.exe

以下列方式之一:

  • 使用GeckoDriver: java -Dwebdriver.gecko.driver=./drivers/windows-driver/geckodriver.exe -jar C:\Users\Administrator\Desktop\selenium-server-standalone-3.0.1.jar -role节点-hub address:4444/grid/register
  • 使用Chromedriver: java -Dwebdriver.chrome.driver=./drivers/windows-driver/chromedriver.exe -jar C:\Users\Administrator\Desktop\selenium-server-standalone-3.0.1.jar -role节点-hub address:4444/grid/register

此外,您需要检查if()循环,因为在System.setProperty()行中有一个混合的System.setProperty()和Linux样式表示,如下所示:

  • GeckoDriver: System.setProperty("webdriver.gecko.driver“、”驱动程序/windows-驱动程序/geckodriver.exe“);
  • ChromeDriver: System.setProperty("webdriver.chrome.driver",“驱动程序/窗口-驱动程序/色度驱动器”);
  • IEDriverServer: System.setProperty("webdriver.ie.driver“、”驱动程序/windows-驱动程序/IEDriverServer.exe“);

geckodriver.exe注释:在系统上,您需要提到扩展.exe部分,例如chromedriver;而在Linux上,您需要去掉扩展.exe部分,例如chromedriver

票数 1
EN

Stack Overflow用户

发布于 2018-10-31 07:47:44

这可能是因为你的ip不匹配。我遇到了同样的错误,我发现我的机器有两个IPv4地址。一个是皮革网,另一个是无线局域网。步骤:

  • 切断Wi。
  • 使用命令:ipconfig检查我的IPv4地址(只有一个IP )。
  • 只有一个IP才能正确地创建会话。
票数 1
EN

Stack Overflow用户

发布于 2018-06-19 02:16:55

也许您正在使用您的办公计算机在节点和集线器之间进行事务处理。

在某种程度上,您可以将代码从办公计算机<=> github <=> AWS EC2控制台中推送。但是,将其注册为节点/中心并尝试执行测试用例可能是不可能的。

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/48991023

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档