Web Automation Testing Framework Improvements

Source: Internet
Author: User
Tags xpath

The Web Automation test Framework (WEBTESTFRAMEWORK) is a framework that is based on the selenium framework and is developed two times with the PageObject design pattern.
First, the scope of application: Traditional Web function Automation test, H5 function Automation test.
Second, Compatibility: it is recommended to use Firefox or Google Chrome because selenium is the best compatibility.
Third, the framework to improve the highlights (better than the selenium framework of the place):

1, using PageObject design mode, all elements of a page (including control) attributes and element operations are encapsulated in 1 class, as follows:

The purpose of this is to understand the decoupling, that is, the test code is separated from the measured Page object code, after the page element changes, only need to modify the measured Page object code (that is, the above class file) without the need to modify the test code, which greatly reduces the late due to page changes resulting in script or use case maintenance costs.
No page element objects are used in the test snippet shown below:

2, using the XPath strategy to find the page elements, but not the use of name, link and other ways to find. Because when the name and link of the page element change, the test code (test case) cannot be executed or unstable during execution. If you use XPath, the test code will not be affected as long as the area of the page element has not changed, and the name, link, and so on, are basically unaffected, and the code looks like this:

Disclaimer: General XPath is based on CSS style, but the demand or probability of css-style change is not very large, in other words, such a period of change is longer, if you want to "status quo", use the ID of the DOM element to locate, this way is not affected by the location of the element, And the effect of the applied style.

3. Separating the page element attribute information from the code, which is separated from the code under test, is also intended to further reduce the maintenance costs of subsequent page changes, i.e., when the page changes, only the XML configuration file information in the corresponding page needs to be modified as follows:

Personal experience:
If you want the framework based on the selenium framework two times to be more extensible, you can use the API provided by the selenium as little as possible, you can do the interface element operation with a lot of JS injection!

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Web Automation Testing Framework Improvements

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.