gpt4 book ai didi

c# - Selenium 网格并行执行

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:16:07 27 4
gpt4 key购买 nike

这是来自 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com