1. Test Automation Basics – Layered test automation

1.1 Unit Automated Testing: Unit automated testing refers to the examination and verification of the smallest testable units in the software. There are pros and cons to delegating unit testing to testers, but overall it’s better for developers to do it. The advantage of testers in unit testing is that they have test thinking and consider more comprehensively when designing test cases. But the downside is also clear. Currently, most testers have a hard time being as familiar with the code under test as developers. The advantage of having developers write unit tests is that no one is more familiar with the code they’re writing than developers. They just need to understand the unit testing framework and some common testing methods to write unit tests, and it’s much easier to locate bugs. So instead of writing unit tests for developers, testers can teach developers how to use unit testing frameworks and methods.

1.2 Interface automation Test: The interface automation test of Web applications can be divided into two categories: module interface test and protocol interface test. (1) Module interface test, mainly testing the call and return between program modules. It focuses on testing calls to a fully functional class, method, or function. (2) Protocol interface test, mainly testing the call to network transmission protocol, such as HTTP/SOAP, etc., generally applied between front-end and back-end development, as well as between different projects. Module interface testing is more suitable for developers to do; Protocol interface testing can be done by both developers and testers.

1.3 UI automated test: UI automated test mainly realizes manual test cases, which can reduce the cost (labor cost and time cost) of system functional regression test. UI automated testing is refined from some functional test cases and is more suitable for testers. In the Book “The Google Way of Testing”, Google divides product testing types into: small test, medium test and large test, using 70% (small), 20% (medium) and 10% (large) ratio, corresponding to the Unit layer, Service layer and UI layer in the test pyramid respectively.

2. Element location

2.1 id positioning

HTML stipulates that ID must be unique in HTML documents, which is similar to the id number of Chinese citizens, which is unique. The id location method provided by WebDriver is to find elements by their ID. The usage of baidu input box and Baidu search button by ID is as follows. Find_element_by_id (“kw”) find_element_by_id(“su”) The find_element_by_id() method locates elements by ID.

2.2 the name positioning

HTML states that name is used to specify the name of the element, so it acts more like a person’s name. The usage of locating the Baidu input box by name is as follows. Find_element_by_name (“wd”) The find_element_by_name() method locates elements by name.

2.3 the class location

Class is used to specify the class name of an element, similar to id and name. The use of class to locate the Baidu input box is as follows. Find_element_by_class_name (“s_ipt”) The find_element_by_class_name() method locates elements by class.

2.4 tag positioning

HTML uses tags to define the elements of different pages. For example, they are used to define input fields, tags are used to define hyperlinks, etc. However, because a tag is often used to define a class of functionality, the probability of identifying an individual element by tag is low. For example, when we open up any page and look at the front-end code, we’ll find plenty of

,,
Such as label. The usage of locating the Baidu input box by tag name is as follows.

find_element_by_tag_name(“input”)

The find_element_by_tag_name() method locates an element by its tag name.

2.5 the link to locate

Link positioning differs from the previous positioning methods in that it is specifically used to locate text links. The code of several text links above the Baidu input box is as follows. View the above code can be found, by name positioning is a good choice. However, in order to demonstrate the use of link positioning, the use of link positioning is given as follows.

Find_element_by_link_text (” news “)

find_element_by_link_text(“hao123”)

Find_element_by_link_text (” map “)

Find_element_by_link_text (” video “)

Find_element_by_link_text (” post “)

The find_element_by_link_text() method locates elements by the textual information between element tag pairs.

Reference: the way of Google’s software testing www.duokan.com/reader/www/…