连接被拒绝通过 Ubuntu 9.04 在 Selenium Grid 1.04 上运行多个环境

发布于 2024-08-24 12:26:45 字数 2599 浏览 3 评论 0原文

我正在编写一个硒网格测试套件,它将在一系列不同的机器上运行。我在 MacBook 上写了大部分内容,但最近将其转移到运行 ubuntu 9.04 的工作机器上。这实际上是我第一次使用 Linux 机器,所以我可能会错过一些非常简单的东西(尽管我已经禁用了防火墙)。

我根本无法让多环境工作正常工作,并且我已经尝试和手动审查了一段时间。任何建议和帮助将不胜感激!

我运行测试时遇到的错误是:

[java] 配置失败:@BeforeMethod startFirstEnvironment("localhost", 4444, "*safari", "http:// /remoteURL:8080/tutor") [java] java.lang.RuntimeException:无法启动 Selenium 会话:错误:连接被拒绝

我认为这可能是 mac 拒绝连接,但使用wireshark我确定在 mac 上没有进行任何连接尝试。这是设置会话的代码,这就是它似乎即将消失的地方

  @BeforeMethod(groups = {"default", "example"}, alwaysRun = true)

  @Parameters({"seleniumHost", "seleniumPort", "firstEnvironment", "webSite"})
  protected void startFirstEnvironment(String seleniumHost, int seleniumPort, String firstEnvironment, String webSite) throws Exception {

 try{
startSeleniumSession(seleniumHost, seleniumPort, firstEnvironment, webSite);
session().setTimeout(TIMEOUT);

  } finally {

  closeSeleniumSession();

  }

}

@BeforeMethod(groups = {"default", "example"}, alwaysRun = true)
@Parameters({"seleniumHost", "seleniumPort", "secondEnvironment", "webSite"})

  protected void startSecondEnvironment(String seleniumHost, int seleniumPort, String    secondEnvironment, String webSite) throws Exception {
 try{
    startSeleniumSession(seleniumHost, seleniumPort, secondEnvironment, webSite); 
session().setTimeout(TIMEOUT);
    } finally {
        closeSeleniumSession();
    }
}

以及用于运行测试的随附构建脚本

  <target name="runMulti" depends="compile" description="Run Selenium tests in parallel (20 threads)">
      <echo>${seleniumHost}</echo>
   <java classpathref="runtime.classpath"
   classname="org.testng.TestNG"
   failonerror="true">

 <sysproperty key="java.security.policy" file="${rootdir}/lib/testng.policy"/>
 <sysproperty key="webSite" value="${webSite}" />
 <sysproperty key="seleniumHost" value="${seleniumHost}" />
 <sysproperty key="seleniumPort" value="${seleniumPort}" />
 <sysproperty key="firstEnvironment" value="${firstEnvironment}" />
 <sysproperty key="secondEnvironment" value="${secondEnvironment}" />
 <arg value="-d" />
 <arg value="${basedir}/target/reports" />
 <arg value="-suitename" />
 <arg value="Selenium Grid Java Sample Test Suite" />
 <arg value="-parallel"/>
 <arg value="methods"/>
 <arg value="-threadcount"/>
 <arg value="15"/>
 <arg value="testng.xml"/>
</java>

I'm writing a selenium grid test suite which is going to be run on a series of different machines. I wrote most of it on my macbook but have recently transfered it over to my work machine, which is running ubuntu 9.04. That's actually my first experience with a linux machine, so I may be missing something very simple (I have disabled the firewall though).

I haven't been able to get the multienvironment thing working at all, and I've been trying and manual reviewing for a while. Any recommendations and help would be greatly, greatly appreciated!

The error I'm getting when I run the test is:

[java] FAILED CONFIGURATION: @BeforeMethod startFirstEnvironment("localhost", 4444, "*safari", "http://remoteURL:8080/tutor")
[java] java.lang.RuntimeException: Could not start Selenium session: ERROR: Connection refused

I thought it might be the mac refusing the connection, but using wireshark I determined that no connection attempt was made on the mac . Here's the code for setting up the session, which is where it seems to be dying

  @BeforeMethod(groups = {"default", "example"}, alwaysRun = true)

  @Parameters({"seleniumHost", "seleniumPort", "firstEnvironment", "webSite"})
  protected void startFirstEnvironment(String seleniumHost, int seleniumPort, String firstEnvironment, String webSite) throws Exception {

 try{
startSeleniumSession(seleniumHost, seleniumPort, firstEnvironment, webSite);
session().setTimeout(TIMEOUT);

  } finally {

  closeSeleniumSession();

  }

}

@BeforeMethod(groups = {"default", "example"}, alwaysRun = true)
@Parameters({"seleniumHost", "seleniumPort", "secondEnvironment", "webSite"})

  protected void startSecondEnvironment(String seleniumHost, int seleniumPort, String    secondEnvironment, String webSite) throws Exception {
 try{
    startSeleniumSession(seleniumHost, seleniumPort, secondEnvironment, webSite); 
session().setTimeout(TIMEOUT);
    } finally {
        closeSeleniumSession();
    }
}

and the accompanying build script used to run the test

  <target name="runMulti" depends="compile" description="Run Selenium tests in parallel (20 threads)">
      <echo>${seleniumHost}</echo>
   <java classpathref="runtime.classpath"
   classname="org.testng.TestNG"
   failonerror="true">

 <sysproperty key="java.security.policy" file="${rootdir}/lib/testng.policy"/>
 <sysproperty key="webSite" value="${webSite}" />
 <sysproperty key="seleniumHost" value="${seleniumHost}" />
 <sysproperty key="seleniumPort" value="${seleniumPort}" />
 <sysproperty key="firstEnvironment" value="${firstEnvironment}" />
 <sysproperty key="secondEnvironment" value="${secondEnvironment}" />
 <arg value="-d" />
 <arg value="${basedir}/target/reports" />
 <arg value="-suitename" />
 <arg value="Selenium Grid Java Sample Test Suite" />
 <arg value="-parallel"/>
 <arg value="methods"/>
 <arg value="-threadcount"/>
 <arg value="15"/>
 <arg value="testng.xml"/>
</java>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浅笑轻吟梦一曲 2024-08-31 12:26:45

是的,我觉得很傻。经过大量的摆弄后,我意识到将构建文件中的 seleniumHost 属性更改为运行该 selenium-RC 实例的机器的 IP。将其作为本地主机只是进行循环或类似的操作。

Yeah, I feel silly. After considerable fiddling I realized that changing the seleniumHost attribute in the build file to the IP of the machine running that instance of selenium-RC. Having it as local host was just making a loop, or something like that.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文