当前位置: 首页 > 知识库问答 >
问题:

不是abe在VM上执行我的selenium测试

丰赞
2023-03-14

我想使用Selenium网格运行我的Selenium测试。为此,我在本地机器(Ubuntu)上设置了集线器,并在Centos VM上设置了节点。我已经运行了以下命令:

    null
          DesiredCapabilities cap1=new DesiredCapabilities();
          String hubURL = "http://10.242.2.6:4444/wd/hub";
          cap1.setBrowserName(browser);
          ChromeOptions option=new ChromeOptions();
          option.addArguments("--headless","--no-sandbox");
          option.merge(cap1);
          driver=new RemoteWebDriver(new URL(hubURL),option);
          driver.get("http://practice.automationtesting.in/my-account/");
          driver.findElement(By.id("username")).sendKeys("pavanoltraining");
          driver.findElement(By.id("password")).sendKeys("Test@selenium123");
          driver.findElement(By.name("login")).click();
11:43:08.894 INFO [RequestHandler.process] - Error forwarding the new session Error forwarding the request Failed to connect to /**nodeIpAddress**:22956
org.openqa.grid.internal.exception.NewSessionException: Error forwarding the request Failed to connect to /**nodeIpAddress**:22956
    at org.openqa.grid.web.servlet.handler.RequestHandler.forwardNewSessionRequestAndUpdateRegistry(RequestHandler.java:94)
    at org.openqa.grid.web.servlet.handler.RequestHandler.process(RequestHandler.java:114)
    at org.openqa.grid.web.servlet.DriverServlet.process(DriverServlet.java:85)
    at org.openqa.grid.web.servlet.DriverServlet.doPost(DriverServlet.java:69)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:707)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:790)
    at org.seleniumhq.jetty9.servlet.ServletHolder.handle(ServletHolder.java:865)
    at org.seleniumhq.jetty9.servlet.ServletHandler.doHandle(ServletHandler.java:535)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:146)
    at org.seleniumhq.jetty9.security.SecurityHandler.handle(SecurityHandler.java:548)
    at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:257)
    at org.seleniumhq.jetty9.server.session.SessionHandler.doHandle(SessionHandler.java:1595)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:255)
    at org.seleniumhq.jetty9.server.handler.ContextHandler.doHandle(ContextHandler.java:1340)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:203)
    at org.seleniumhq.jetty9.servlet.ServletHandler.doScope(ServletHandler.java:473)
    at org.seleniumhq.jetty9.server.session.SessionHandler.doScope(SessionHandler.java:1564)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.nextScope(ScopedHandler.java:201)
    at org.seleniumhq.jetty9.server.handler.ContextHandler.doScope(ContextHandler.java:1242)
    at org.seleniumhq.jetty9.server.handler.ScopedHandler.handle(ScopedHandler.java:144)
    at org.seleniumhq.jetty9.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
    at org.seleniumhq.jetty9.server.Server.handle(Server.java:503)
    at org.seleniumhq.jetty9.server.HttpChannel.handle(HttpChannel.java:364)
    at org.seleniumhq.jetty9.server.HttpConnection.onFillable(HttpConnection.java:260)
    at org.seleniumhq.jetty9.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:305)
    at org.seleniumhq.jetty9.io.FillInterest.fillable(FillInterest.java:103)
    at org.seleniumhq.jetty9.io.ChannelEndPoint$2.run(ChannelEndPoint.java:118)
    at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:333)
    at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:310)
    at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:168)
    at org.seleniumhq.jetty9.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:126)
    at org.seleniumhq.jetty9.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:366)
    at org.seleniumhq.jetty9.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:765)
    at org.seleniumhq.jetty9.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:683)
    at java.base/java.lang.Thread.run(Thread.java:834)
Caused by: java.net.ConnectException: Failed to connect to /172.17.0.1:22956
    at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:247)
    at okhttp3.internal.connection.RealConnection.connect(RealConnection.java:165)
    at okhttp3.internal.connection.StreamAllocation.findConnection(StreamAllocation.java:257)
    at okhttp3.internal.connection.StreamAllocation.findHealthyConnection(StreamAllocation.java:135)
    at okhttp3.internal.connection.StreamAllocation.newStream(StreamAllocation.java:114)
    at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.java:42)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.java:93)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.java:126)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:147)
    at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.java:121)
    at okhttp3.RealCall.getResponseWithInterceptorChain(RealCall.java:200)
    at okhttp3.RealCall.execute(RealCall.java:77)
    at org.openqa.selenium.remote.internal.OkHttpClient.execute(OkHttpClient.java:103)
    at org.openqa.grid.internal.TestSession.sendRequestToNode(TestSession.java:422)
    at org.openqa.grid.internal.TestSession.forward(TestSession.java:229)
    at org.openqa.grid.web.servlet.handler.RequestHandler.forwardNewSessionRequestAndUpdateRegistry(RequestHandler.java:91)
    ... 35 more
Caused by: java.net.ConnectException: Connection timed out (Connection timed out)
    at java.base/java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.base/java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:399)
    at java.base/java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:242)
    at java.base/java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:224)
    at java.base/java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
    at java.base/java.net.Socket.connect(Socket.java:609)
    at okhttp3.internal.platform.Platform.connectSocket(Platform.java:129)
    at okhttp3.internal.connection.RealConnection.connectSocket(RealConnection.java:245)

我试过所有可能的解决办法,但还是想不出这个问题。

共有1个答案

柳绪
2023-03-14

试试这个:

            private WebDriver driver;
            private ChromeOptions chromeOptions;
            private DesiredCapabilities caps;
            // Test on VM
            private final String URL = "http://10.242.2.6:4444/wd/hub";
            ChromeOptions options = new ChromeOptions();
            options.addArguments("--headless");
            options.setCapability(CapabilityType.BROWSER_NAME, "chrome");
            options.setCapability(CapabilityType.PLATFORM_NAME, Platform.LINUX);
            options.addArguments("Proxy", "null");
            options.setExperimentalOption("useAutomationExtension", false);
            options.addArguments("--disable-dev-shm-usage");
            options.addArguments("--no-sandbox");
            options.addArguments("window-size=1920,1080");
            options.addArguments("--disable-gpu");
            options.addArguments("start-maximized");
            options.addArguments("--allow-insecure-localhost");
            options.addArguments("--ignore-certificate-errors");
            System.out.println(options);
            driver = new RemoteWebDriver(new URL(URL), options);
            driver.manage().window().fullscreen();

我测试过了,这对我有效。如果您实际上已经将节点连接到集线器,并且在控制台中看到了这一点,那么这应该可以工作。

 类似资料:
  • 我试图在Linux上用jenkins构建我的maven项目,但是我的selenium测试失败了,出现了这个异常 运行TestSuite配置TestNG:org.apache.maven.surefire.testng.conf.TestNG652Configurator@61db2215测试运行: 6,失败: 1,错误: 0,跳过: 5,时间流逝: 0.51秒 我知道我在窗口而不是Linux上使用

  • 我的Gradle项目使用了KotlinDSL和JUnit5/Jupiter(以及Kotlin作为编程语言),Gradle似乎没有正确地接受我的任何测试。当我在命令行上运行Gradle测试时,它告诉我 不管我怎么尝试。然而,在我的IDE中,我可以轻松地运行项目中的每个单个测试类,而不会出现任何问题。

  • 案例1: 使用时: 获取异常: 看到的超文本标记语言套件异常:java.lang.RuntimeException:java.lang.RuntimeException: GoogleChrome在路径中找不到!请将包含“chrome.exe”或“google-chrome”或“GoogleChrome”的目录添加到您的PATH环境可用,或显式指定GoogleChrome路径,如下所示:*goog

  • 问题内容: 我知道您可以在 Dalvik的VM 中运行几乎所有Java,而在 Java的VM中 可以运行,但局限性不是很清楚。有没有人遇到任何重大绊脚石?任何主要的图书馆有麻烦吗?任何编译为Java字节码的语言( Scala , Jython 等)均无法按预期工作? 问题答案: Dalvik在许多方面将无法处理或将不会以与标准Java字节码完全相同的方式来处理它们,尽管其中大多数都是相当先进的。

  • 问题内容: 我有一个包含单元测试的Go文件,其中一些使用了公共变量。我正在测试的代码中使用了另一个全局变量。所有这些都可能导致问题。 在Go中,当我们执行位于同一文件中的测试时,它们如何运行?并行还是下一个不会在前一个完成之前开始? 问题答案: 测试起来真的很容易: 使用运行它,输出显示它是顺序的: 因此,正常的测试是依次执行的,但是请不要忘记未定义顺序:如何依次运行golang测试? 还要注意,

  • 版本 Liquibase:3.6.2 Spring Boot:2.1.0.RELEASE MySQL / MariaDB: mysql Ver 15.1 Distrib 10.1.25-MariaDB,用于Win32(AMD64) H2:1.4.197 目标 我有一个迁移脚本,它将数据从两个表转换为一个。该脚本是用SQL编写的,并且工作正常(通过手动执行来验证)。此外,当使用H2数据库运行迁移时,