当前位置:网站首页>Still worrying about how to write web automation test cases? Senior test engineers teach you selenium test case writing hand in hand
Still worrying about how to write web automation test cases? Senior test engineers teach you selenium test case writing hand in hand
2022-07-06 06:15:00 【The elegance of testing】
To write Selenium The test case is to simulate a series of operations of the user on the browser , Complete automated testing through scripts .
Advantages of writing test cases :
Open source , free .
Support multiple browsers IE,Firefox,Chrome,Safari.
Support for multiple platforms Windows,Linux,Mac.
Support for multiple languages Python,Java,C#.
Yes Web Good support .
Simple , flexible .
Support distributed test case execution .
Introduce dependencies
Dependency is introduced to call webdriver To interact with the browser to realize the operation steps .
- Python edition
from selenium import webdriver
Flow of test cases
A test case is a set of sets provided to the system under test in order to implement the test , This set of collections contains : Test environment 、 Operation steps 、 Test data 、 Expected results, etc .
Be careful : The final result of a test case is only one : Success or failure .
The three core elements are : title 、 step 、 Expected results
- title : Is a description of the test case , The title should clearly express the content of the test case
- step : Describe the test execution process
- Expected results : Provide the expected results of test execution , The expected results are generally based on demand , If the actual results are consistent with the expected results, the test passes , On the contrary, failure .
Practical drill
The first is to import... At the top of the code Selenium My bag , The second is the naming of test methods 、 testing procedure 、 Assertion . The content of the test case is to assert whether the content displayed by opening Baidu page is equal to the expected value .
Python edition
from selenium import webdriver
# The title of the test is test_search
def test_search():
driver = webdriver.Chrome()
# Test steps
driver.get('https://www.baidu.com')
search = driver.find_element_by_id('su').get_attribute('value')
# Assert the expected result
assert search == " Baidu "
Here to assert whether the content displayed by opening Baidu page is equal to the expected value . Because the content actually obtained should be Baidu, not Baidu , So the assertion is wrong .
FAILED [100%]
test_demo.py:3 (test_search)
use Baidu Search != Baidu
Expected : Baidu
Actual : use Baidu Search
<Click to see difference>
def test_search():
driver = webdriver.Chrome()
driver.get('https://www.baidu.com')
search = driver.find_element_by_id('su').get_attribute('value')
> assert search == " Baidu "
E AssertionError: assert ' use Baidu Search ' == ' Baidu '
test_demo.py:9: AssertionError
Last : It can be in the official account : Sad spicy bar ! Get one by yourself 216 Page software testing engineer interview guide document information 【 Free of charge 】. And the corresponding video learning tutorial is free to share !, It includes basic knowledge 、Linux necessary 、Shell、 The principles of the Internet 、Mysql database 、 Special topic of bag capturing tools 、 Interface testing tool 、 Test advanced -Python Programming 、Web automated testing 、APP automated testing 、 Interface automation testing 、 Testing advanced continuous integration 、 Test architecture development test framework 、 Performance testing 、 Safety test, etc. .
I recommend one 【Python Automated test communication group :746506216】, We can discuss communication software testing together , Learn software testing together 、 Interview and other aspects of software testing , Help you advance quickly Python automated testing / Test Development , On the road to high pay .
Friends who like software testing , If my blog helps you 、 If you like my blog content , please “ give the thumbs-up ” “ Comment on ” “ Collection ” One Key triple connection !
边栏推荐
- Overview of three core areas of Mathematics: algebra
- Caused by:org.gradle.api.internal.plugins . PluginApplicationException: Failed to apply plugin
- Gtest之TEST宏的用法
- 测试周期被压缩?教你9个方法去应对
- nodejs实现微博第三方登录
- Pat (Grade B) 2022 summer exam
- Réflexions sur la sécurité des données (réimpression)
- The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
- Web界面元素的测试
- 通过修改style设置打印页样式
猜你喜欢
随机推荐
Idea new UI usage
A complete collection of necessary learning websites for office programmers
公司視頻加速播放
把el-tree选中的数组转换为数组对象
PAT(乙级)2022年夏季考试
请求转发与重定向
(中)苹果有开源,但又怎样呢?
调用链监控Zipkin、sleuth搭建与整合
Digital triangle model acwing 1015 Picking flowers
[Thesis code] SML part code reading
Understanding of processes and threads
Overview of three core areas of Mathematics: algebra
假设检验学习笔记
异常检测方法总结
D - How Many Answers Are Wrong
【eolink】PC客户端安装
数据库-当前读与快照读
Dynamic programming -- knapsack problem
黑猫带你学UFS协议第18篇:UFS如何配置逻辑单元(LU Management)
GTSAM中李群的运用