My understanding of Selenium in the Page Object Design Pattern

First, what is the PO mode?

PO is an abbreviation of the Page Object, PO mode is one of the best design patterns development practices of test automation project.
The core idea is to package interface elements reduce redundant code while in the latter part of maintenance, if the positioning element changes only
need to adjust the page element package code, test cases to improve the maintainability, readability.

Two, PO mode is divided into three:

Here is what I do Baidu login page:
Here Insert Picture Description

Base (object library layer): Store with some basic operations on the web page and apply to the entire package Base Project
Here Insert Picture Description
Here Insert Picture Description
Page (operation level): The Base page, add positioned elements, the method used to call the Base page package, each page module should have a page, are not common between the page page (such as login page does not apply to the same shopping cart page)
Here Insert Picture Description

Case (business layer): page in Example. It is achieved through the use cases Page page calling the method.

Login Use Case:
Here Insert Picture Description
Run the use cases:
Here Insert Picture Description

When you run all the code, not his path into the unittest framework to run, run to right-click directly, or you want to perform a single test case unittest framework it into operation in the framework of unittest
PS: I would eat this before QAQ loss

These are the codes, went on to say under my understanding of the Page Object design pattern:

1, first of all, we want to put all of the underlying operating base page, page for page calls

2, page page To call base page, which can effectively improve the reusability, high reusability of code, we only need to locate specific elements can be loaded to note it is that we write in the page page into the more, then we will be more relaxed in the implementation of automated test scripts.

For example, when I had to locate an element, and when you want to operate, then we can get other targeting methods once, so that for the first time acquired less than a specific value elements, can effectively get to the second element values
Here Insert Picture Description
if the page page, the page of the lack of a common code base we want to use, then you can return to base page supplement, base pages and pages about the same page, the full complement of all, then we are doing it will save time and effort when automated testing, improve efficiency

3, case page page page we only need to call in the code can be

Finally, if necessary, you can also run the results generated test reports stored separately:
Here Insert Picture Description
Here Insert Picture Description

Finally, if the positioning elements of change, then we only need to modify the positioning elements, have to say in the page page, this pattern has won my love ~ ~ ~

Automated Test group: 762 141 168

Welcome you automated testing, interface testing, mobile terminal testing and related test your friends to join
me here for you, and common progress, GO GO!

Published 10 original articles · won praise 13 · views 406

Guess you like

Origin blog.csdn.net/weixin_46457203/article/details/105000697