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);
	
相关推荐
阿斯加德D2 小时前
我的世界生活大冒险整合包下载高版本2026最新分享
测试工具·游戏·游戏程序·生活·材质
Land03293 小时前
指纹浏览器自动化集成方案|多浏览器RPA适配实战记录
运维·人工智能·爬虫·python·selenium·自动化·rpa
littlebigbar3 小时前
让AI自己说说,AI 智能体在软件测试中能做什么?
人工智能·测试工具
测试员周周4 小时前
【Appium 系列】第07节-API测试封装 — BaseAPI 的设计与实现
开发语言·人工智能·功能测试·测试工具·appium·自动化·测试用例
yuanpan5 小时前
Python + Selenium 浏览器自动化测试与网页自动登录
开发语言·python·selenium
骄傲的心别枯萎8 小时前
WireShark抓取rtsp包
网络·测试工具·wireshark
Luminbox紫创测控9 小时前
汽车(EV)内外饰材料老化测试与标准
人工智能·测试工具·汽车·安全性测试·测试标准
光影6271 天前
Selenium自动化测试---实战踩坑实录
python·selenium·测试工具·百度
掌动智能1 天前
传统数据工厂之死:RunnerAgent如何开启AI驱动的“数据生产”新纪元
人工智能·测试工具·自动化
wuchen10042 天前
使用Postman测试grpc接口-传参错误的反例
测试工具·postman