selenium大量并发连接驱动超时

我的业务是根据数据生成一大片报表图,组成一个word文档,量大概10~100之间,挨个执行太慢了,15分钟左右,为了加快速度使用了多线程,而多线程又被机器速度限制,一旦跑的多了,就会有线程被挂起,这时就会报连不上驱动的问题。找了大量文章,都是在写访问超时时间,没有写驱动超时的。。。

解决方案

使用ChromeDriverServiceChromeOptions创建页面对象指定连接驱动超时时间,设置为5分钟,

java 复制代码
	//System.setProperty(global.getConfig("webDriver.driverName"), getUrlStr(global.getConfig("webDriver.driverPath")));
	System.setProperty("webdriver.chrome.driver", "D:/developkit/driver/chromedriver.exe");
	ChromeOptions chromeOptions = new ChromeOptions();
	//无头模式
	chromeOptions.setHeadless(false);
	//设置浏览器完整路径,有时会报找不到浏览器的问题,指定路径
	chromeOptions.setBinary("D:/Program Files (x86)/Google/Chrome/Application/chrome.exe");
	
	Duration duration = Duration.of(5, ChronoUnit.MINUTES);//5分钟超时时间 - 驱动连接超时时间
	ChromeDriverService service = new ChromeDriverService.Builder()
                //超时时间
                .withTimeout(duration)
                //执行驱动,由chromeOptions提供
                //.usingDriverExecutable(getUrl(global.getConfig("webDriver.driverPath")))
                .build();
//        service.start();
	return new ChromeDriver(service, chromeOptions);
	
相关推荐
Run Freely9373 小时前
接口测试-postman-全局变量与环境变量
测试工具·postman
我的xiaodoujiao7 小时前
从 0 到 1 搭建 Python 语言 Web UI自动化测试学习系列 8--基础知识 4--常用函数 2
前端·python·测试工具·ui
程序员小远10 小时前
常用的测试用例
自动化测试·软件测试·python·功能测试·测试工具·职场和发展·测试用例
(时光煮雨)10 小时前
【Python进阶】Python爬虫-Selenium
爬虫·python·selenium
依旧很淡定2 天前
Selenium(Python)创建Chrome浏览器实例
chrome·python·selenium
小熊出擊3 天前
【pytest】finalizer 执行顺序:FILO 原则
python·测试工具·单元测试·pytest
云闲不收3 天前
接口请求工具对比 apifox apipost swagger postman等
测试工具·postman
sitellla3 天前
Testify Go测试工具包入门教程
git·测试工具·其他·golang
我的xiaodoujiao3 天前
从 0 到 1 搭建 Python 语言 Web UI自动化测试学习系列 9--基础知识 5--常用函数 3
前端·python·测试工具·ui
可可南木3 天前
ICT 数字测试原理 8 - -VCL 的测试参数
开发语言·功能测试·测试工具·pcb工艺