Web automated testing (3) Selenium+beatuifulsoup

little bottle
Release: 2019-04-10 13:15:09
forward
2009 people have browsed it

Regarding Selenium’s automated testing and the use of functions, there are too many basic tutorials on the Internet. I will not list them all here. You can refer to other tutorials or the official website. This article mainly discusses the solution design of web automation testing and the difficulties that the editor personally thinks.

System architecture

As shown below, based on our background automated testing framework (part of the architecture of the web extension in this figure, other parts involve Confidential to the company and not shown in the picture), Selenium has been extended. Based on Selenium, the setting of page objects has been expanded, and a retry doubling delay waiting time mechanism has been introduced to improve the setting success rate. The page action module uniformly implements page actions. One function implements one action, ensuring the independence of each page action. Therefore, if you need to add different combinations of execution steps in later versions, you only need to call the functions inside.

The data acquisition module is divided into three layers, namely database data acquisition module, page data acquisition module, and web application log data acquisition module. In this way, it is easy to organize the various members of the team, and each person can implement the module they are best at and integrate quickly.

Web automated testing (3) Selenium+beatuifulsoup

A large source of demand for web automated testing is browser compatibility testing, so the framework design must consider how to test multiple browsers at once . The blogger's plan is to put the test case set into each browser instance and execute them sequentially one by one.

Definition and analysis of page elements

The positioning of page elements has always been a difficulty in web automation testing, because many companies’ web The code implemented by developers is not standardized. Despite this, when implementing automated testing, everyone should try to avoid using css and xpath to define, because the readability and maintainability are too poor. Try to use id, name, class name to define. Corresponding to some elements without id, name, class name, try to use find_elements_by_tag_name and then parse its attributes to locate the element, or use find_element_by_xpath(".."), find_element_by_xpath("../..") to find the superior or superior element.

Use beatuifulsoap to parse

Beatuifulsoap is used by many crawlers because of its powerful parsing function. It is said that in the solution, if the crawler functions are It can certainly meet all the needs of automated testing. The blogger combined find_element_by_xx(table_id).get_attribute('innerHTML') and beatuifusoup. In the current projects, there are almost no elements that cannot be parsed and located. For example, if there is a certain dynamic id or name, first use the fuzzy matching of beatuifulsoap. Then by parsing other attributes to locate the id or name, and then calling find_element_by_xx, you can achieve a perfect positioning solution. Mom no longer has to worry about developers not writing id, or name value

[Recommended course: Python video tutorial]

The above is the detailed content of Web automated testing (3) Selenium+beatuifulsoup. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!