简体   繁体   English

Selenium / TestNG DataProvider-如何结合页面对象模型构造Excel工作表

[英]Selenium/TestNG DataProvider - How to structure Excel sheets in combination with Page Object Model

Background 背景

I am developing a new approach to automated testing using Selenium/TestNG/POM. 我正在开发一种使用Selenium / TestNG / POM进行自动化测试的新方法。 So far, we have very promising results and automated large parts of our regression testing. 到目前为止,我们已经获得了非常有希望的结果,并且自动化了大部分回归测试。

Now, we came to the step of expanding our test set by parametrizing them. 现在,我们通过参数化来扩展测试集。 We have end2end flows defined over multiple pages, where the pages are modeled into page objects. 我们在多个页面上定义了end2end流,其中页面被建模为页面对象。 Most of these pages are forms, and in the end we get a resulting product/report that combines all the information. 这些页面大多数都是表格,最后我们得到一个包含所有信息的最终产品/报告。

Now my problem statement 现在我的问题陈述

We want to use Excel sheets so our business analysts can input the parameters and the expected values. 我们希望使用Excel工作表,以便我们的业务分析师可以输入参数和期望值。 But I am struggling to find a good way to structure the sheets. 但是我正在努力寻找一种构造纸张的好方法。 The naive approach would be to have a column for every parameter, and a line for every test case. 天真的方法是每个参数都有一列,每个测试用例都有一行。 A slightly better approach would probably be to use a different sheet for each page object, in a workbook, having a different workbook for each flow. 更好的方法可能是在工作簿中为每个页面对象使用不同的工作表,为每个流程使用不同的工作簿。

But my fear is that, by doing this, we are undoing all the good the POM brings us. 但是我担心这样做会破坏POM给我们带来的所有好处。 If we need to change something (add a field in one of the screens for example), we need to regenerate all the excel sheets, or at least manually update each one. 如果需要更改某些内容(例如,在一个屏幕中添加一个字段),则需要重新生成所有Excel工作表,或者至少手动更新每个工作表。 This is not that much better than having to update each scenario. 这并不比必须更新每个方案要好得多。 In fact, we probably still have to edit all the scenario's (for example, if the new field is "name", add everywhere a "fillName('John')" step. 实际上,我们可能仍需要编辑所有方案(例如,如果新字段为“ name”,则在各处添加“ fillName('John')”步骤。

Is there a better way? 有没有更好的办法? Or is the manual work unavoidable? 还是手动工作不可避免? Or am I implementing POM incorrectly if I still need to adapt most scenarios everytime I need to add a field? 还是在每次需要添加字段时仍需要适应大多数情况的情况下,是否错误地实施了POM?

Trying to create yet another solution which use Excel as page object source you are bringing youself back to stone age. 尝试创建另一个使用Excel作为页面对象源的解决方案,您正将自己带回到石器时代。 Use modern frameworks to handle Page Objects issues eg JDI with elements typification or Selenide wich provides more concise way. 使用现代框架来处理页面对象问题,例如元素类型为JDISelenide的方法提供了更简洁的方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM