多个浏览器上的Selenium Grid:每个测试用例是否应为每个浏览器具有单独的类? [英] Selenium Grid on Multiple Browsers: should each test case have separate class for each browser?

查看:210
本文介绍了多个浏览器上的Selenium Grid:每个测试用例是否应为每个浏览器具有单独的类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试整理我的第一个数据驱动测试框架,该框架通过Selenium Grid/WebDriver在多个浏览器上运行测试.现在,我在自己的类中拥有每个测试用例,并且对浏览器进行了参数设置,因此它在每个浏览器中都运行一次每个测试用例.

I'm trying to put together my first Data Driven Test Framework that runs tests through Selenium Grid/WebDriver on multiple browsers. Right now, I have each test case in it's own class, and I parametrize the browser, so it runs each test case once with each browser.

在大型测试框架上常见吗?还是应该将每个测试用例复制并微调到其各自类中的每个浏览器?因此,如果我正在测试chrome,firefox和IE,是否应该为每个类提供类,例如:"TestCase1Chrome","TestCase1FireFox","TestCase1IE"?还是只是"TestCase1"并配置测试以使其在每个浏览器中运行3次?只是想知道别人是怎么做的.

Is this common on big test frameworks? Or, should each test case be copied and fine tuned to each browser in it's own class? So, if I'm testing chrome, firefox, and IE, should there be classes for each, like: "TestCase1Chrome", "TestCase1FireFox", "TestCase1IE"? Or just "TestCase1" and parametrize the test to run 3 times with each browser? Just wondering how others do it.

将每个测试用例的测试参数化为一个类,可以更轻松地维护非浏览器特定的代码,而针对每个浏览器用例重复一个类,则可以更轻松地维护特定于浏览器的代码.例如,当我说浏览器特定的代码时,单击一个项目.在ChromeDriver上,您无法单击某些元素的中间,而在FirefoxDriver上则可以.因此,您可能仅需要两个不同的代码块来单击一个元素(当它在中间不可单击时).

Parameterizing the tests into a single class per test case makes it easier to maintain the non-browser specific code, while duplicating classes, one for each browser case, makes it easier to maintain the browser-specific code. When I say browser specific code, for example, clicking an item. On ChromeDriver, you cannot click in the middle of some elements, where on FirefoxDriver, you can. So, you potentially need two different blocks of code just to click an element (when it's not clickable in the middle).

对于您中使用Selenium的QA工程师中的那些人,这里的最佳实践是什么?

For those of you that are employed QA Engineers that use Selenium, what would be best practice here?

推荐答案

我目前正在从事一个项目,该项目每天要进行大约75k-90k测试.我们将浏览器作为参数传递给测试.原因是:

I am currently working on a project which runs around 75k - 90k tests on daily basis. We pass the browser as a parameter to the tests. Reasons being:

  1. 正如您在问题中提到的那样,这有助于维护.
  2. 我们看不到太多特定于浏览器的代码.如果您有太多特定于浏览器的代码,那么我会说webdriver本身存在问题.因为,selenium/webdriver的优点之一是只编写一次代码,即可在任何受支持的浏览器上运行它.

我看到的代码结构与您提到的代码结构之间的区别是,我没有每个测试用例的测试类.测试根据我测试的功能进行划分,每个功能都有一个类.该类将所有测试作为方法保存.我使用testNG以便可以并行调用这些方法.可能这不适合您的AUT.

The difference I see between my code structure and the one you mentioned in question is, I don't have a test class for each test case. Tests are divided based on the features that I test and each feature will have a class. And that class will hold all the tests as methods. I use testNG so that these methods can be invoked in parallel. May be this won't suite your AUT.

这篇关于多个浏览器上的Selenium Grid:每个测试用例是否应为每个浏览器具有单独的类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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