c# - Selenium 网格并行执行

标签 c# java selenium-grid

这是来自 Selenium 网格。如何编写 java/C# 代码来进行并行执行。

这就够了吗?

ISelenium selenium1 = new DefaultSelenium("localhost", 5555, "*iehta", "http://localhost/");
ISelenium selenium2 = new DefaultSelenium("localhost", 5556, "*iehta", "http://localhost/");
ISelenium selenium4 = new DefaultSelenium("localhost", 5557, "*iehta", "http://localhost/");


selenium1.Start();
selenium2.Start();
selenium3.Start();

因为当我运行 http://localhost:4444/console即使我从上运行代码,也有 3 个可用的远程控制,但有 0 个 Activity 的远程控制。

来自 ant 的代码,我 100% 不理解。为什么会有参数
<arg value="-parallel"/>

<target name="run-demo-in-parallel" description="Run Selenium tests in parallel">
    <java classpathref="demo.classpath"
        classname="org.testng.TestNG"
        failonerror="true"

        >
      <sysproperty key="java.security.policy" file="${basedir}/lib/testng.policy"/>
      <sysproperty key="webSite" value="${webSite}" />
      <sysproperty key="seleniumHost" value="${seleniumHost}" />
      <sysproperty key="seleniumPort" value="${seleniumPort}" />
      <sysproperty key="browser" value="${browser}" />

      <arg value="-d" />
      <arg value="${basedir}/target/reports" />
      <arg value="-suitename" />
      <arg value="Selenium Grid Demo In Parallel" />
      <arg value="-parallel"/>
      <arg value="methods"/>
      <arg value="-threadcount"/>
      <arg value="10"/>
      <arg value="-testclass"/>
      <arg value="com.thoughtworks.selenium.grid.demo.WebTestForASingleBrowser"/>
    </java>
  </target>

最佳答案

为什么会有参数

<arg value="-parallel"/>?

这是为了testng。这将并行而不是顺序运行所有方法/类/测试。您可以查看有关此属性的更多信息 here .您已经注册了 3 个 RC,理想情况下您应该看到所有 3 个都被用于执行。您可以检查网格控制台链接以查看利用率 - http://localhost:4444/console其中 localhost 是集线器运行的 IP,port 是集线器正在监听的端口号。

编辑: 更改您的代码以指向 selenium 集线器端口而不是 RC 端口。默认情况下,集线器端口将为 4444。还要确保您已经启动了环境为 *iehta 的 RC 节点。

`ISelenium selenium1 = new DefaultSelenium("localhost", 4444, "*iehta",` "http://localhost/");

关于c# - Selenium 网格并行执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6904065/

相关文章:

selenium - 使用 css 选择器 python 选择一个元素

java - Selenium 网格: how to maximize browser window using RemoteWebDriver and ChromeDriver

c# - MVC 中的动态下拉列表

c# - 实例化 GameObject 的正确方法?

c# - 为什么无法序列化 DataTable。未设置数据表名称?

c# - 使用 Windows 服务手动实现 IoC

java - 没有为SQL参数'orgName'提供值:此SqlParameterSource为空

java - Android 中的线程

java - 获得概率图中位数的更好方法是什么?

selenium - 网格上的多个实例如何处理 Selenium 屏幕截图?