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
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了