当前位置:网站首页>UI automation test farewell from now on, manual download browser driver, recommended collection
UI automation test farewell from now on, manual download browser driver, recommended collection
2022-07-28 04:48:00 【Software testing Intelligence Agency】
Everyone is doing UI When automating , What is the most annoying , Is it element positioning or browser and driver compatible debugging ? Let's move on

One .SeleniumWebDriver
SeleniumWebDriver Is a program that allows control Web Browser Library . It provides a cross browser API, Can be used to drive using different programming languages ( Such as Java、JavaScript、Python、C# or Ruby) Browser ( Such as Chrome、Edge or Firefox etc. ).Selenium WebDriver The main purpose of is to realize Web Automated testing of applications .
SeleniumWebDriver Use the native support of each browser to automate . For this reason , We need to use Selenium WebDriver API A browser named Driver Binary file . Now the drivers of mainstream web browsers are ChromeDriver (Chrome) ,geckoDriver (Firefox) , perhaps msededriver (Edge).WebDriver API The communication with the driver binary file is called W3C WebDriver( Formerly known as JSON Wire Protocol) The standard agreement of . then , Use the native function of each browser to complete the communication between the driver and the browser .
We manually download the corresponding version of the corresponding browser according to different browsers and browser versions driver, Set system properties .
System.setProperty("webdriver.chrome.driver", "/path/to/chromedriver");
System.setProperty("webdriver.gecko.driver", "/path/to/geckodriver");
System.setProperty("webdriver.edge.driver", "/path/to/msedgedriver");
System.setProperty("webdriver.opera.driver", "/path/to/operadriver");
System.setProperty("webdriver.ie.driver", "C:/path/to/IEDriverServer.exe");
We're doing it UI When automating, we often encounter browser upgrades that lead to driver Version mismatch problem , The solution is to manually download the corresponding version driver, For starters , It's not a simple job , Is there any way to automatically download the corresponding version according to different browsers driver Well ? The answer is yes , This is what we are talking about this time WebDriverManager. Yes Java and Python They all support it .
Two .WebDriverManager brief introduction
WebDriverManager It's an open source Java library , Of course, there are Python edition , It is executed in a fully automated way Selenium WebDriver Management of required drivers ( For example, download 、 Setup and maintenance ). in addition , In version 5 in ,WebDriverManager Other related functions are also provided , For example, find the browser installed in the local system , structure WebDriver object ( Such as ChromeDriver、FirefoxDriver、 EdgeDriver etc. ) , stay Docker The browser runs seamlessly in the container , And monitoring function .
3、 ... and .WebDriverManager actual combat (Java edition )
1.pom.xml Add WebDriverManager rely on
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>5.0.3</version>
<exclusions>
<exclusion>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</exclusion>
</exclusions>
</dependency>
2. Create a new test script , To test the
import io.github.bonigarcia.wdm.WebDriverManager;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
/**
* @author author : The way test engineers grow up
* @version Creation time :2022/7/3
* Class description : Automatic download Chrome Browser driven
*/
public class OperateBrowserDriver {
public static void main(String[] args) throws InterruptedException {
WebDriverManager.chromedriver().setup();
WebDriver driver = new ChromeDriver();
driver.get("http://www.cnblogs.com/mrjade/");
Thread.sleep(1000);
driver.quit();
}
}
3. Execution results

4.driver Storage path ( With Macos For example )

Four .WebDriverManager actual combat (Python edition )
1. install
pip install webdriver-manager
2. Use
# coding=utf-8
'''
@Author : The way test engineers grow up
@Time : 2022/7/3 12:13
@Desc : Methods described
@Software: PyCharm
'''
import time
from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
driver = webdriver.Chrome(ChromeDriverManager().install())
driver.get("https://www.baidu.com/")
time.sleep(5)
driver.quit()
3. Execution results

4.driver Storage path ( With Macos For example )

Four . Official documents
For more browser operations, please refer to the official website documentation
https://bonigarcia.dev/webdrivermanager/
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 !
边栏推荐
- [函数文档] torch.histc 与 paddle.histogram 与 numpy.histogram
- [Sylar] framework -chapter24- support business modularization
- 【二、移动web网页开发】2D&3D转换与动画、移动端布局、响应式布局
- System clock failure of database fault tolerance
- Interview fraud: there are companies that make money from interviews
- Tiantian AMADA CNC bending machine touch screen maintenance rgm21003 host circuit board maintenance
- Leetcode 18. sum of four numbers
- High number_ Chapter 4__ curvilinear integral
- 启发国内学子学习少儿机器人编程教育
- 外卖系统 文件上传
猜你喜欢
![String 0123456789abcdef, what is the number of substrings (not empty and not the same string itself) [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]](/img/78/efe3d70a4bfe8ac0c9b58b54d02b00.png)
String 0123456789abcdef, what is the number of substrings (not empty and not the same string itself) [Hangzhou multi tester] [Hangzhou multi tester _ Wang Sir]
![[每日一氵]上古年代的 Visual Studio2015 安装](/img/b1/066ed0b9e93b8f378c89ee974163e5.png)
[每日一氵]上古年代的 Visual Studio2015 安装

go-zero单体服务使用泛型简化注册Handler路由

05.01 string

(克隆虚拟机步骤)

Blooming old trees -- quickly build a map bed application with imageprocessor

Youxuan database participated in the compilation of the Research Report on database development (2022) of the China Academy of communications and communications

Ma Yi, Shen Xiangyang, Cao Ying's latest AI overview is hot! It took 3 months to build, netizens: required papers

Improve the core quality of steam education among students

MySQL: data types and operators
随机推荐
Zhejiang University and other recent review papers on deep learning new drug design
启发国内学子学习少儿机器人编程教育
printf()打印char* str
Leetcode 15. sum of three numbers
CMake使用基础汇总
Harmony's Application on the shelves reported an error. The solution of "please use the API of the released version to develop the application and apply for listing"
(2.4) [service Trojan -slimftp] introduction and use
Wang Shuang assembly language detailed learning notes 3: registers (memory access)
RuntimeError: stack expects each tensor to be equal size, but got [8] at entry 0 and [2] at entry 2
01-Node-Express系统框架搭建(express-generator)
Dynamic SQL and paging
(clone virtual machine steps)
王爽汇编语言详细学习笔记三:寄存器(内存访问)
High number_ Chapter 4__ Curvilinear integral_ Exercise solution
你必需要了解的saas架构设计?
Use animatedbuilder to separate components and animation, and realize dynamic reuse
NAT基本原理与私有IP
Phpstorm2022 connect to the database
【sylar】框架篇-Chapter11-Socket 模块
Ma Yi, Shen Xiangyang, Cao Ying's latest AI overview is hot! It took 3 months to build, netizens: required papers