如何使用 Selenium Grid2 在一个集线器上运行多个浏览器
我正在运行一个测试:
DesiredCapabilities capability = DesiredCapabilities.Firefox();
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);
ISelenium selenium = new WebDriverBackedSelenium(driver, "http://localhost/");
selenium.Start();
这将运行 Firefox 浏览器,并且在 http://localhost:4444/grid/console
Web 控制台视图中我可以看到一个 Firefox 浏览器正在运行。如何在节点上并行使用多个浏览器?
我正在使用 Grid2 wiki 页面在此处找到
I'm running a test:
DesiredCapabilities capability = DesiredCapabilities.Firefox();
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444/wd/hub"), capability);
ISelenium selenium = new WebDriverBackedSelenium(driver, "http://localhost/");
selenium.Start();
This runs the Firefox browser, and in the http://localhost:4444/grid/console
web console view I can see that one Firefox browser is running. How can I use more than one browser on the node in parallel?
I'm using the Grid2 wiki page found here
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您需要同时触发 5 个测试 - 所有测试都指向同一个集线器,才能使用所有浏览器。在接收到来自不同测试的命令后,集线器会将这些命令传递给与功能匹配的 RC。您可以在此页面中查看更多详细信息: http://selenium-grid.seleniumhq.org/how_it_works .html。
根据此网站:-
编辑:
上面给出的站点适用于 Selenium 1.x 版本,不适用于 Grid 2.0。但是,运行并行测试的基本概念仍然相同
EDIT2:
步骤和示例程序如下。请注意,这是一个非常基本的测试,仅向您展示 Grid 如何并行运行测试。
第 1 步 - 启动 Grid Hub
java -jar selenium-server-standalone.jar -role hub
第 2 步 - 启动 RC 节点。 例如,我们使用的测试是 webdriver 测试。所以我们需要启动webdriver节点。该命令将启动一个支持 5 个 firefox 浏览器、5 个 googlechrome 和 1 个 IE 浏览器的 webdriver 节点。这是 webdriver 的默认配置。
第 3 步 - 创建 5 个独立的程序,类似于下面给出的程序。该程序采用 JAVA 语言。您需要将其更改为您需要的语言。将类名称更改为 Program2、Program3 等。如前所述,这不是并行运行测试的最佳方法。您需要使用 testNG 或 jUnit 同时触发多个测试。由于这本身就是一个不同的主题,因此我不会在这里进行解释。
第 4 步 - 同时运行所有 5 个程序。
第 5 步 - 观看网格并行运行 5 个测试的神奇效果。 :)
You need to trigger 5 tests simultaneously - all pointing to the same hub, to use all the browsers. On receiving the commands from different tests, hub would pass those commands to RCs matching the capability. You can see more details in this page : http://selenium-grid.seleniumhq.org/how_it_works.html.
Per this site:-
EDIT:
The above given site was for Selenium 1.x version and not for Grid 2.0. However, the underlying concept for running parallel tests remains the same
EDIT2:
Steps and example programs are below. Please note that this is a very basic test ONLY to show you how Grid runs tests in parallel.
Step1 - Start Grid Hub
java -jar selenium-server-standalone.jar -role hub
Step2 - Start RC nodes. The tests which we are using for example are webdriver tests. So we need to start webdriver nodes. This command would start a webdriver node which supports 5 firefox browsers, 5 googlechrome and 1 IE browser. This is the default config for webdriver.
Step 3- Create 5 separate programs similar to the one given below. This program is in JAVA. You need to change it to the language you need. Change class name to Program2,Program3 etc. As mentioned earlier, this is not the best way to run tests in parallel. You need to use testNG or jUnit to trigger multiple tests at the same time. Since that is a different topic by itself am not going to explain it here.
Step 4 - Run all 5 programs simultaneously.
Step 5 - Watch the grid doing the magic of running 5 tests in parallel. :)