Some thoughts on the Web Automation

Source: Internet
Author: User
Tags xpath

How to write a Web Automation test framework

Here are a few things to solve first

1. Login log out how to connect

Web Automation is actually a simulation of the operation, by clicking on the page elements, input data and so on to achieve the page jump and data validation, usually web automation is composed of many automation use cases, each use case can be run alone, can also be run in conjunction with other use cases. At this point, if the use case requires the user to log in to execute, you need to verify whether to log in before running, if you log in to continue to run, if you do not have to log in first.

2. Links between pages

Another scenario is that one use case is specific to Page 3, but before you reach Page 3, you must go through Page 1 and Page 2, at which point you need to verify that the current page is Page 3 (usually judged by a feature element) before running the use case, and if it is Page 3 then the use case can continue to execute. Otherwise, it needs to be advanced to Page 1 and page 2 before the use case can continue to run.

3. How page elements are positioned

Usually is determined by the specific product, the common positioning method has ID, name, CSS, Xpath, you can use a single positioning method, can also be mixed use. CSS and XPath provide a rich variety of functions that can be positioned almost anywhere on a page.

4. Elements and Page waits

When you run an Automation use case, many factors affect the load duration of the page element, and if you do not set the appropriate wait time, it is likely that running automation will fail because the element or element is not visible. The Webdirver provides a wide range of waiting functions for us to use.

5. Validation of data correctness

The most important checkpoint of automation in addition to checking the page jump is the correct validation of data, in what way to verify the correctness of the data needs to be based on the specific product to judge, such as the return of JSON data, the data display on the page.

6. Test Report

After the completion of the automation, do not print test reports, reports in what manner (HTML, TXT, etc.), whether the need to automatically open in the browser after running, the report needs information, the wrong use cases need not take screenshots.


After the above problem is resolved, you can proceed to the following specific details:

1. What programming language to use

For example: Java, Python, JavaScript, Ruby, etc.

2. What automation tools are used

Example: Selenium, Webdriver, QTP, etc.

3. What are the existing, good concepts and ways for us to use

Example: PageObject, pagefactory, etc.

4. Can I extract the components that are common on the page?

Example: Dropdown box, scroll bar, check box, Radio box, drop-down list, table, etc.

5. What additional scripting languages and tools are required

Example: Ant, maven, testng, etc.


Finally, analyze the list of solutions, compare the pros and cons, choose the best combination to write an automated framework



How to write good Web automation use cases

1. Good programming habits

In Java, for example, the package name, class name, method name and so on have the corresponding standards, following these standards can not only improve our writing efficiency, but also write the automation use cases are easy to read and debug.

2. Add Comment

Annotate, so that others can understand your use case well.

3. Clear logic, easy to read

There is a logical connection between the previous action and the next step, and the same as the actual operation, the benefit is that the problem can be quickly positioned to the point of failure.

4. Minimize duplication of code

This, do not repeat.

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.