Web自动化之浏览器启动
一、环境准备
1、本地引入jar
从http://selenium-release.storage.googleapis.com/index.html?path=3.9/,下载selenium-server-standalone-3.9.1.jar到D盘根目录下

2、打开DOS命令窗口,命令行进入到Maven安装目录下,用命令打包,输入并执行命令:mvn install:install-file -Dfile=D:\selenium-server-standalone-3.9.1.jar -DgroupId=org.selenium -DartifactId=selenium-server-standalone -Dversion=3.9.1 -Dpackaging=jar
参数说明:
Dfile为要安装的Jar的本地路径,DgroupId为要安装的jar的Group Id,DartifactId为要安装的jar的 Artificial Id,Dversion为jar包版本,Dpackaging为打包类型,例如jar。

3、本地引入成功

4、pom文件添加依赖
<dependency>
<groupId>org.selenium</groupId>
<artifactId>selenium-server-standalone</artifactId>
<version>3.9.1</version>
</dependency>

如果一栏添加报错,可以查看下MAVEN中setting文件设置是否正确



二、Chrome浏览器启动
1、下载Chromedriver
从https://chromedriver.storage.googleapis.com/index.html,下载ChromeDriver驱动,下载后解压文件,找到文件名为chromedriver.exe的文件,放到工程tool文件夹下。
下载版本的时候要注意,与自己目前的浏览器版本要一致


2、运行下面代码,就可以在Chrome中打开百度,在关闭

参考自:https://www.cnblogs.com/longronglang/p/15034413.html
浙公网安备 33010602011771号