[英]What is the best way to store data in a Page Object Model Framework
Im building an automation framework in selenium using the Page Object Design Pattern. 我使用页面对象设计模式在硒中构建了一个自动化框架。 Following are some of the data that Im using and where i have stored them 以下是我使用的一些数据以及我将其存储在何处
Once the framework starts growing it would be hard to store all the data it would be hard to organize the data. 一旦框架开始增长,将很难存储所有数据,也将很难组织数据。 I did a some research on how others have implemented the way they store data in their framework. 我对其他人如何实现他们在框架中存储数据的方式进行了一些研究。 Here is what I found out, 这是我发现的,
Since there are lot of options out there, I thought of getting some feedback on what is the best way to store data and how everyone else has stored there data. 由于那里有很多选择,我想就什么是最好的数据存储方式以及其他人如何存储数据的方式获得一些反馈。
JSON或任何临时数据存储是最佳选择,因为它是一个框架,其目的是为不同项目重用。
I advice using Interfaces for each device type to store multiple type selectors, example: 我建议对每种设备类型使用接口来存储多个类型选择器,例如:
import static org.openqa.selenium.By.cssSelector;
import static org.openqa.selenium.By.linkText;
import static org.openqa.selenium.By.xpath;
public interface DesktopMainPageSelector {
By FIRST_ELEMENT = cssSelector("selector_here");
By SECOND_ELEMENT = xpath("selector_here");
By THIRD_ELEMENT = id("selector_here");
}
than, just implement these selectors from whatever you need them. 只需从您需要的任何地方实现这些选择器即可。
You can also use enums with for a more complex structure. 您还可以将枚举与更复杂的结构一起使用。
I found this as best solution, because its easy to manage large numbers of selectors 我发现这是最好的解决方案,因为它易于管理大量选择器
I don't see any problem with the way you have stored your data. 我认为您存储数据的方式没有任何问题。
The framework doesn't really grow, the automation suite does. 框架并没有真正增长,自动化套件却在增长。 As long as you keep the data stored in the 3 places above consistently, I think you should be fine. 只要您将数据存储在上面3个位置上,就可以了,我认为应该没问题。 The only issue I've run into with this approach is that sometimes certain pages have a LOT of functionality on them so the page objects grow quite large. 我使用这种方法遇到的唯一问题是,有时某些页面上具有很多功能,因此页面对象会变得很大。 In those cases, we found a way to divide the page into smaller chunks, eg one page had 22 tabs, each consisting of a different panel. 在那种情况下,我们找到了一种将页面分成较小的块的方法,例如,一个页面有22个选项卡,每个选项卡由一个不同的面板组成。 In that case, we broke the page object into 22 different class files to keep the size more manageable and then hooked them all back into the main page as properties, eg mainPage.Panel1.someMethodOnPanel1();
在那种情况下,我们将页面对象分成22个不同的类文件,以使大小更易于管理,然后将它们作为属性重新挂回到主页面,例如mainPage.Panel1.someMethodOnPanel1();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.