“并行"中的 Selenium 测试执行使用“TestNG" [英] Selenium Test Execution in "Parallel" using 'TestNG'

查看:29
本文介绍了“并行"中的 Selenium 测试执行使用“TestNG"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 TestNG 在不同浏览器中并行运行 Selenium 测试 案例.(使用:Selenium-Grid)我想在不同的浏览器中使用不同的(相同的变化)数据执行相同的测试用例.例如.如果在不同浏览器上注册",则不能使用相同的数据.如同会员在一个网站上注册后不能再次注册一样.

I am running the Selenium Test cases in parallel using TestNG in different browsers. (usage of: Selenium-Grid) I want to execute the same test case in different browser with different(variation of same) data. For eg. a same data can not be used in case of 'registration' over different browsers. As once the member is registered on a website can not register again in the same.

要求:同时在 3 个浏览器 IE、FF、Chrome 中注册测试用例.我正在使用

Req: Registration test case in 3 browsers IE,FF,Chrome in parallel. I am using

@DataProvder(name="RegData",parallel=true) 
public Object[][] getRegData() { 
Object[][] data = {{"Max","Male","Italy"},{"James","Male","France"},{"Alex","Male","Spain"}}; 
return data; 
}

此数据用作测试数据.但实际情况是每个测试用例执行 3 次.每个测试用例与每个数据"实例.所以 3 个测试用例 x 3 个数据"条目 = 9 次执行.每个数据实例只能使用一次.总执行次数应该只有 3

This data is utilized as Test Data. But what happens is each test case is executed 3 times. Each Test-case with each 'data' instance. so 3 Test Cases x 3 'data' entries = 9 executions. Each data instance should be utilized only once. Total executions should be only 3

推荐答案

dp 的目的就是要做到这一点.使用不同的数据运行一组步骤.您正在 3 个浏览器和 3 个数据中运行测试用例.所以每个浏览器都会运行 3 个数据中的每一个.这是预期的.

The intention of the dp is to do exactly that. Run a set of steps with different data. You are running the testcase in 3 browsers and with 3 data. So each browwser would run with each of the 3 data. That is expected.

如果您希望一个数据应该转到一个浏览器,那么浏览器也应该作为数据提供者的一部分传递.因此 data1 与 browser1,data2 与 browser2 和 data3 与浏览器 3 - 这将确保每个浏览器运行一个数据.

If you want that one data should go to one browser then the browser too should be passed as part of the dataprovider. So data1 with browser1, data2 with browser2 and data3 with browser 3 - this would ensure each browser runs with one data.

在您的流程中,您似乎正在测试注册三次.无论您提到什么,设计似乎都不正确.

In your flow, it seems you are testing registration thrice. The design seems to be incorrect from whatever you mention.

这篇关于“并行"中的 Selenium 测试执行使用“TestNG"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆