Chapter 8 Page Object - Selenium3 automated testing

Chapter 8 Page Object

Page Object design pattern is one of the best development practices UI test automation project, its main features is reflected in the package of interface interaction details of the test cases focus more on business operations, thus improving the maintainability of test cases.

This tutorial exercises practice, please click to download the source code

8.1 know Page Object

When writing tests for Web page elements on the Web page needs to operate. However, if the direct operating elements on a Web page in the test code, then this code is extremely fragile, because the UI will change frequently.
Page Object principle shown in Figure 8-1.


A basic rule of thumb is that the object page: all people can do, page objects through client software can do. Thus, it should provide an easy programming interfaces, and hide the underlying window member. When accessing a text box, and returns a string should obtain is achieved by an access method (Accessor Method), using Boolean values should box, the button should be expressed as a method name-oriented behavior. page object shall behavior on the GUI controls all queries and manipulate the data for the encapsulation method.
A good rule of thumb is to change even if the specific elements of the interface page object does not change should occur.
Although this term is page object, but that does not mean a need to establish such an object for each page. For example, there are significant elements of the page can be independent as a page object. The rule of thumb is to aim to page through modeling, so users of the application to make sense.

Page Object is a design pattern, the design should follow this model in the development of automated test to write code.

Page Object should follow the following principles for development:

● Page Object should be easy to use.
● a clear structure, such as the page object corresponding to PageObjects, PageModules corresponding page content.
● Write only test content, do not write the basis of content.
● prevent boilerplate code where possible.
● need to manage their own browser.
● Select the browser at run time, rather than the class level.
● not require direct contact Selenium.

 

Guess you like

Origin www.cnblogs.com/MarlonKang/p/12469355.html