当前位置:网站首页>CSDN salary increase technology selenium automated test stack summary
CSDN salary increase technology selenium automated test stack summary
2022-06-28 19:51:00 【Test Architect Bei fan】
Preface :
I'm uncle fan , Cut the crap and go straight to dry goods
【 The end of the article leaves a lot of benefits for everyone 】
One 、Selenium automated testing ( be based on python)
1、Selenium brief introduction :
1.1 Selenium It is mainly used for Web A collection of tools for automated testing of applications .Selenium Test runs directly in browser , The essence is to drive the browser , Simulate the operation of the browser , Like jumping 、 Input 、 Click on 、 Drop down, etc. , To get the result after rendering the web page , It can support multiple browsers, such as ,chorme,FireFox,IE etc. .
1.2 Selenium WebDriver: A common testing framework in the industry , Not only is web The standard of testing , At the same time, it is also the underlying core driver framework in the field of mobile testing ;
1.3 Python It's dynamic language ;
1.4 Selenium It includes a series of tool components :
1)Selenium IDE: It's embedded in FireFox Browser plug-ins , Used in Firefox Record and playback on Selenium Script , Although only in Firefox Next use , But it can convert recorded scripts into various Selenium WebDriver Supported programming languages , Then it can be extended to a wider range of browser types ;
2) Selenium WebDriver: Can support multiple languages , A set for operating the browser API; Support various types of browsers , Cross operating system ,WebDriver Provides complete , Used to implement web Third party libraries for automated testing ;
3) Selenium Standalone Server: Include Selenium Grid、 Remote control 、 Distributed deployment, etc , Can be realized Selenium Efficient execution and expansion of scripts ; utilize Grid Make automated tests run in parallel , Even across platforms 、 Run in a heterogeneous environment ;
2、 be based on python Of selenium WebDeriver Environmental installation
Selenium Can automatically manipulate the browser to do a lot , Such as simulating the interaction with the browser , And support to most mainstream browsers ; First, you need to choose a language to write automated scripts , And this language needs to have Selenium client library Support , choice Python;
2.1 install python and selenium, Different installation versions can be downloaded from the platform
1) install selenium
Win:pip install selenium
Mac: pip3 install selenium
2) install WebDriver, This tool is for selenium Use Chrome.( notes :webdriver The corresponding browser version and selenium The version corresponds to )

3)WebDriver The installation path
Win: Copy webdriver To Python Installation directory
Mac: Copy webdriver To /usr/local/bin Under the table of contents
2.2 PyCharm Set up
1)PyCharm There are two versions : Community and professional , The Community Edition is free , You can download and use ;
2) In the use of PyCharm when , Need configuration Python Interpreter , We choose to support selenium Of Python Version interpreter ;

3、Selenium WebDriver be based on Python Implementation script
3.1 according to webDriver Provides a series of object positioning methods , Get elements , Implement test cases
3.2 webDriver Common element positioning methods are :
① id location :find_element_by_id()
② name location :find_element_by_name()
③ class location :find_element_by_class_name()
④ link location :find_element_by_link_text()
⑤ partial link location :find_element_by_partial_link_text()
⑥ tag location :find_element_by_tag_name()
⑦ xpath location :find_element_by_xpath()
⑧ css location :find_element_by_css_selector()
4、unittest Write unit tests and output test reports
Use only Selenium WebDriver, There are still some things that cannot be achieved : such as Implementation of test preconditions 、 Test post conditions , Compare the expected results with the actual results , Check the status of the program , Generate test reports and other functions ; So you need to use unittest To create based on Python Of Selenium WebDriver The test script ;
4.1 What is? unittest
Unittest It is also known as PyUnit, It's from java Widely used in program development Unit Inspired by , have access to unittest Create a comprehensive test suite for your project ,unittest Have the ability to create test cases 、 test suite , Test fixture capability ;
unitest Components :
1)Test Fixture( Test fixture ): You can define the preparation work before single or multiple test execution and the cleaning work after test execution ;
2)Test Case( The test case ):unittest The smallest unit of test execution in , Pass the verification unittest Provided assert Method to verify the response after a specific set of operations and inputs ,unittest A file named TestCase The base class , Can be used to create test cases ;
3)Test Suit( test suite ): A test suite is a collection of multiple tests or test cases , It is a set of tests created for the corresponding functions and modules of the program under test , The test cases in a test suite will be executed together ;
4)Test Runner( Test the actuator ): The test executor is responsible for test execution scheduling and generating test results to users , The test executor can use a graphical interface 、 Text interface or specific return value to display the test execution results ;
5)Test Report( Test report ): The test report shows a summary of the success or failure status of all execution cases , Include the expected and actual results of failed test steps , There is also a summary of the overall operation status and operation time ;
4.2 Use unittest To write the Selenium WebDriver test
1)Arrange: Initialize preconditions , Initialize the tested object , Related configurations and dependencies ;
2)Act: Perform functional operations ;
3)Assert: It is used to verify whether the actual results are consistent with the expected results ;
4.3 Use TestCase Class to implement a test
1) Integrate TestCase Class and add test methods to each test in the test class to create a single test or a set of tests ;
2)TestCase Medium assert Method , The main task is call assertEqual() To verify the results ;assertTrue() To verify the condition ;assertRaises To verify the expected exception , In addition to adding tests , You can also add test fixtures ,setUp() Methods and tearDown() Method ;
3) A test case is from setUp() Method start execution , So you can perform some initialization tasks before each test starts ; This method has no parameters , No return value , Then write test Method , These test methods are named test start , This naming convention notifies test runner Which method represents the test method ;
notes :test runner Every test method you can find , Will be executed before the test method is executed setUp() Method , This helps ensure that each test method can rely on the same environment .
4)tearDown() Method will be called after the test execution is completed , Used to clean up all initial values ;
5) In order to pass the command line test , We can add pairs to the test main Method call ; We will pass on verbosity Parameters so that the detailed test results are displayed on the console ;
The test case code is shown in the following figure (Testcase01.py), If the test passes , The browser will eventually exit , If something goes wrong , The console will print out relevant information ,

( chart -Testcase01.py)
4.4 Create... For a set of tests TestSuite
1) application unittest Of TestSuites characteristic , Different tests can be grouped into a logical group , Then set up a unified test suite , And execute through a command ; Concrete adoption TestSuites、TestLoader and TestRunner Class to implement ;
2) Use TestSuites Class to define and execute the test suite , Add multiple testables to a test suite , You can also use TestLoader and TextTestRunner Create and run test suites , An example is shown below (TestSuites.py);

( chart -TestSuites.py)
4.5 Use unittest Extension to generate HTML Formatted test report
unittest An extension of HTMLTestRunner You can generate test reports . The generated test report format is more friendly , You can view the test results , And can go deep into every detail . The example code is shown in the figure below (testsuiteshtml.py)

( chart -testsuiteshtml.py)
The test report is shown in the figure below (TestReport)

5、 summary
The above contents are mainly selenium be based on python, Use WebDriver、Unittest Components , Use element positioning , Complete the test case , Simple steps to output test reports , Other problems may be encountered in actual operation , Solve specific problems .
a key : Learning materials of course, learning is inseparable from materials , Of course, here is also prepared for you 600G Learning materials
Required first Focus on Then private my keyword 【000】 Get it for free Note that the keywords are :000
doubt : Why pay attention first ? return : Because if you don't pay attention, you can't see the private letter
Project practice
app project , Bank Project , Medical Project , Online retailers , Finance

Large scale e-commerce projects

Full set of software test automation test teaching video

300G Download tutorial materials 【 Video tutorial +PPT+ Project source code 】

A complete set of software testing automation testing factory has been

python automated testing ++ A complete set of templates + Performance testing


It's said that the iron juice who has paid attention to me for three consecutive years has been promoted, raised and made a fortune !!!!
边栏推荐
- kettle(六):基于Kettle的数据库全量备份
- Severity code description project file line suppress status error lnk2038 detected a mismatch of "runtimelibrary": the value "md\u dynamicrelease" does not match the value "mdd\u dynamicde"
- 5G NR MBS架构介绍
- 秒杀系统设计
- Concours de segmentation des images gastro - intestinales de kaggle Baseline
- F(x)构建方程 ,梯度下降求偏导,损失函数确定偏导调整,激活函数处理非线性问题
- 电子科大(申恒涛团队)&京东AI(梅涛团队)提出用于视频问答的结构化双流注意网络,性能SOTA!优于基于双视频表示的方法!...
- Bayesian inference problem, MCMC and variational inference
- C # application interface development foundation - form control
- 【Go语言刷题篇】Go从0到入门5:Map综合复习、条件语句、循环语句练习
猜你喜欢

Variational graph auto-encoders (VGAE)

5g NR MBS architecture introduction

Installation and configuration of CGAL in PCL environment 5.4.1

There are thousands of roads. Why did this innovative storage company choose this one?

Markdown mermaid种草(1)_ mermaid简介

Severity code description project file line suppress status error lnk2038 detected a mismatch of "runtimelibrary": the value "md\u dynamicrelease" does not match the value "mdd\u dynamicde"

论文笔记:Universal Value Function Approximators

NanoPC-T4(RK3399) game1 oled(I2C)显示时间天气温度

Ffmpeg usage in video compression processing

echart:横向柱状图的类目文字位置调整
随机推荐
微信小程序_8,视图与逻辑
Past blue bridge cup test questions ants catch cold
internship:术语了解及着手写接口
论文3 VScode&texlive&SumatraPDF打造完美书写论文工具
How to learn JS through w3school / how to use the JS reference manual of w3school
图神经网络入门 (GNN, GCN)
Pyinstaller打包pikepdf失败的问题排查
PCL calculation of center and radius of circumscribed circle of plane triangle
jvm内存结构
Bayesian inference problem, MCMC and variational inference
Severity code description project file line suppress status error lnk2038 detected a mismatch of "runtimelibrary": the value "md\u dynamicrelease" does not match the value "mdd\u dynamicde"
Intelligent computing system 1 environment construction
变分自编码器 (Variational Autoencoders, VAEs)
odoo15 Module operations are not possible at this time, please try again later or contact your syste
类加载机制与对象的创建
数论 --- 欧拉函数、筛法求欧拉函数、欧拉定理、费马小定理详细证明
PCL 计算平面三角形外接圆的圆心和半径
Matlab 2D or 3D triangulation
《数据安全法》出台一周年,看哪四大变化来袭?
Markdown Mermaid planting grass (1)_ Introduction to Mermaid