(Fifty-four) automated testing Page Object design pattern advanced applications - the Cognition Page Object

Essays and records to facilitate their access to fellow travelers.

#------------------------------------------------I ------------------------------------------- dividing line is a shame

  Learning before selenium automation, it is best to learn HTML, CSS, JavaScript and other knowledge, help to understand the principles of operation and positioning elements. About python and selenium install any additional information please search on their own here do not introduced, all examples are performed using python3.6 + selenium.

#------------------------------------------------I ------------------------------------------- dividing line is a shame

Page Object Design Pattern

Page Object is selenium one of the best design patterns automation development practice test project, which is mainly reflected in the details of the package of interactive interface, so you can make the test case is more focused on business rather than the details of the interface, thereby enhancing the readability of test cases .

Understanding Page Object

Page Object advantage of design patterns are as follows:

  1. Reducing code duplication.
  2. Improve test readability.
  3. Improve the maintainability of test cases, especially for UI frequent changes in the project.

As for the Web when writing test page, the need to manipulate Web page elements. However, if the direct operation in the test code in HTML elements, then your code is extremely fragile, because the UI change frequently. We can be a page object is encapsulated into a HTML page, and then provide the application-specific API to manipulate elements on the page, rather than in HTML search around in, Page Object principle as shown below:

 

 

 

Page A basic rule of thumb is that objects: all people can do, Page objects through software clients are able to do. Thus, it should provide an easy programming interfaces and hides the underlying window member. So should access a file box via an access method ( accessor Method, to achieve) obtain and returns a string, check boxes should use a Boolean value, the button should be expressed as a behavior-oriented method name. Page objects should be in the GUI all acts query and manipulate data encapsulation as a method of control. A good rule of thumb is to change even if the specific controls, Page interface object does not change should occur.

 

Although the term "page" object, but that does not mean a need to establish such an object for each page, for example, are important 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.

Guess you like

Origin www.cnblogs.com/lirongyang/p/11595871.html