Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Learn Python+Selenium and build Web automation framework minute by minute!

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Python+selenium to achieve UI automation testing, to have some HTML and xth foundation, of course, python foundation must be able to. The author suggests taking some time to understand the basics so as not to be confused later.

1 What is Selenium?

Selenium is a powerful tool set. Support rapid development of test automation and execution of tests on multiple browser platforms. Support multiple development languages, such as Python, Java, ruby, C#, etc. This time Python3 is selected as the development language.

The advantages of Python testing

Small learning difficulty, short development cycle. For most testers in China, coding experience is insufficient, and python is a good entry language. The glue language integrates with C++, Java, COM, and. NET,Object-C.

The test department has to do unit testing and interface testing. Because of the proportion of personnel, it is impossible for testers to master multiple languages at the same time. Python can implement unit testing after interface encapsulation of C/C++, Java, Object-C. Simple grammar, clear, reduce the difficulty of late maintenance.

III. Automated test framework

A typical automatic test framework generally includes use case management module, automatic execution controller, report generation module and log module. These modules are not isolated from each other, but complement each other.

The logical units of each module are described below:

Use Case Management Module

The use case management module includes operation units such as adding, modifying, deleting, etc. These units also involve the pattern of use case writing, management of test data, reusable library, etc.

automatic executive controller

Controllers are organizing modules that automate use case execution and are primarily responsible for how use cases are executed. Typical controllers are graphical user interfaces (GUI) and commandline+ files.

report generation module

The report generation module is mainly responsible for generating reports after executing the use cases. The reports are mostly in HTML format, and the information mainly includes the execution of the use cases and the corresponding summary reports. You can also add email functionality.

log module

Log module is mainly used to record the execution of the use case, so as to investigate the failure information of the use case and track the execution of the use case more efficiently.

IV. Design and implementation of automation framework

scheme design

1. Programming code selection python3

2. Selenium + Unit Testing Framework unittest

Compiler: IDE/pycharm

structure design

cases:

Use Case Management by Function

use-case realization

com

config

edata: environment configuration module

env.json, envroment.yaml realize city selection and SIT, UAT environment switching

sdata: data configuration

All kinds of data json files, bank data, product information, personal information, etc.

elements: element definition

locator.py Element definition, menu, into_a_management.yaml, etc.

lib

Third-party module references, version management

report

Management log reports

report.xlsx automated execution results generate excel reports

report.xlsx

index.html

Modules in need of improvement

For the existing implementation of the test framework, it can already meet the automation needs of web objects, but there are still some areas that can be improved, such as:

Can you try data driven for some test cases

Add screenshot functionality

Encapsulates functions in the By library in selenium for more efficient positioning of page elements, etc.

Continuous improvement combined with industry-leading automation frameworks and practices

V. Summary

Selenium-based web automation frameworks are lightweight and flexible, enabling rapid development of automated test cases. Combined with the above framework design ideas, I hope to help you design and implement the future web automation framework.

Welcome to join 51 software testing family, here you will get [latest industry information],[free testing tool installation kit],[software testing technology dry goods],[interview job skills]... 51 Learn and grow together with you! Looking forward to your joining: QQ group: 755431660

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report