Why is Page Object required?

Source: Internet
Author: User
Why is Page Object required?

Page Object (PO) is a common mode in the automated Acceptance Test of the interface. I want to discuss the necessity of Po with @ slot's nickname. I will express my point of view in this article.

The main value of Po is the encapsulation of interface interaction details, which enables the test case to focus more on the business rather than the Interface Details and improve the readability of the test case, this is actually very beneficial to the implementation of behavior driven development (BDD), acceptance test driven development (atdd) or specification by example (SBE.

For example, if I have an identity information page, enter the name, age, gender, ID card number, and other information, so my test case may be like this (Java + selenium ):
Driver. findelement (by. Name ("name_field"). sendkeys ("God ");
Driver. findelement (by. Name ("age_field"). sendkeys ("99999 ");
Driver. findelement (by. Name ("sex_field"). sendkeys ("unknown ");
Driver. findelement (by. Name ("social_id_field"). sendkeys ("invalid ");

As you can see, in addition to the business, the preceding statement contains a lot of noise at the Implementation Layer. Even if the browserbot mode is used to package the noise, the test case includes four steps:
Mysendkeybyname ("name_field", "God ");
Mysendkeybyname ("age_field", "99999 ");
Mysendkeybyname ("sex_field", "unknown ");
Mysendkeybyname ("social_id_field", "invalid ");

The noise is greatly reduced by using the browserbot mode, but there are still some, such as the interface ID. If the Po mode is used, the test case can be further simplified,
Idpage. inputbasiicinfo ("God", "99999", "unknown", "invalid ");

In fact, this forms its own testing DSL for specific applications, encapsulates a large number of interface interaction details, and enhances the readability of the test cases.

Another major benefit of using PO is to reduce redundancy. If I need to input identity information in 10 cases, therefore, I do not need to repeat the four steps for 10 times. Instead, I only need to call inputbasicinfo ten times, which will greatly reduce the case maintenance cost in the future.

Therefore, the power of Po is not easy to understand when a tester writes test cases in the main scenario by himself, because he does not need to exchange cases with development and business personnel, he will not write many repeated actions. However, I believe that when he really tries atdd, BDD or SBE, when he starts to write some important abnormal branch processes, when he starts to frequently maintain and modify cases for new requirements, I think he will be more aware of the role of Po.

In the last sentence, Po is neither a panacea nor the only truth. Improving the readability of test cases and avoiding redundancy of case steps is the ultimate goal. Welcome to join the layer-Based Automated Testing QQ Group 20442181 for discussion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.