selenium大量并发连接驱动超时

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

解决方案

使用ChromeDriverService和ChromeOptions创建页面对象指定连接驱动超时时间,设置为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);
	
相关推荐
Wokoo76 小时前
Selenium 核心 API 解析(三)
python·功能测试·selenium
ck0135798 小时前
图片抠图怎么做?从背景去除到透明 PNG 的实用教程
人工智能·测试工具·音视频·媒体·视频
LT101579744411 小时前
2026年国内有哪些好用的性能测试工具?
测试工具
技术人生00112 小时前
Selenium 工程化模板(日志+异常截图,可直接复制使用)
python·selenium·测试工具
Wokoo712 小时前
Selenium:元素定位、动态适配与性能优化(二)
前端·selenium·自动化
ck01357915 小时前
视频转 GIF 的基本流程与文件大小优化
前端·测试工具·html·音视频·视频
菜鸟阿达1 天前
Postman 有哪些免费/开源的替代品?2026 年接口工具选型参考
测试工具·开源·postman
代码不停2 天前
自动化测试(java)
java·开发语言·selenium·自动化
雪雪爱冲浪2 天前
2026 年网络爬虫领域的Puppeteer vs. Playwright
爬虫·网络协议·测试工具·接口隔离原则