java - 如何在创建 RemoteWebDriver 时声明两个节点?

标签 java selenium selenium-webdriver grid remotewebdriver

这里我创建了一个集线器和一个节点,我想创建另一个节点。

如何使用多个节点初始化我的 RemoteWebdriver

public void setUp() throws MalformedURLException{
    baseUrl="http://10.77.16.133/cpos-alttech/";
    nodeUrl="http://172.29.69.175:8080/wd/hub";
    DesiredCapabilities capability = DesiredCapabilities.internetExplorer();
    capability.setCapability(InternetExplorerDriver.INTRODUCE_FLAKINESS_BY_IGNORING_SECURITY_DOMAINS, true);
    capability.setBrowserName("internet explorer");
    capability.setPlatform(Platform.WINDOWS);
    driver = new RemoteWebDriver(new URL(nodeUrl), capability);

}

最佳答案

我建议将节点注册到集线器,如下所述:

我通常喜欢先启动一个集线器(使用下面的“启动集线器”命令),然后将节点注册到集线器(使用下面的“启动节点”命令)。

在代码中,我传递了适合集线器配置的所需功能。

引用Starting Selenium-Grid :

启动中心:

To start a hub with default parameters, run the following command from a > command-line shell. This will work on all the supported platforms, > >Windows Linux, or Mac OSX.

java -jar selenium-server-standalone-2.44.0.jar -role hub

启动节点:

To start a node using default parameters, run the following command from > a command-line.

java -jar selenium-server-standalone-2.44.0.jar -role node -hub http://localhost:4444/grid/register

因此,为了添加更多节点,只需从所需的机器或进程运行“启动节点命令”

关于java - 如何在创建 RemoteWebDriver 时声明两个节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28019123/

相关文章:

ruby-on-rails - Heroku/Rails 上的 Chromedriver:无法加载应用程序:Selenium::WebDriver::Error::WebDriverError:不是文件: "/usr/local/bin/chromedriver"

selenium-webdriver - 如何使用 webdriver 中的 css 选择器按值定位元素?

java - Selenium 程序抛出编译错误 org.openqa.selenium.internal.Killable cannot be resolved

java - 为什么 Java 8 有 Arrays.parallelSort() 但没有 Collections.parallelSort()?

python - selenium webdriver上传文件

python - 如何加速 python selenium find_elements?

python - 如果忽略 SIGCHLD,Firefox Webdriver 将无法工作

java - "Cannot perform this action on a not sealed instance"java.lang.IllegalStateException异常

java - 请推荐有关线程和并发的好书/网站?

java - 获取 TreeMap 中的三个最高值