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);
	
相关推荐
小白学大数据1 小时前
利用 Selenium 与 BeautifulSoup 构建链家动态爬虫
开发语言·爬虫·selenium·beautifulsoup
2501_924064111 小时前
2025年主流接口测试工具对比分析与最佳实践指南
测试工具
oh-pinpin2 小时前
【jmeter】-脚本-接口自动获取token
测试工具·jmeter·压力测试
卓码软件测评5 小时前
第三方软件测试机构【Gatling源码的本地编译构建方法】
测试工具·性能优化·单元测试·测试用例
侧耳倾听11112 小时前
基准测试框架JMH
java·测试工具
Wpa.wk1 天前
接口测试 - 接口测试工具 Postman-基础使用
经验分享·测试工具·lua·postman
可可南木1 天前
ICT测试日志 --4--日志记录的格式 中
功能测试·测试工具·pcb工艺
卓码软件测评1 天前
第三方软件测评机构:【Gatling构建JSON请求体StringBody、ElFileBody和Pebble模板的使用】
测试工具·性能优化·json·测试用例
美团程序员1 天前
软件测试面试题总结【含答案】
功能测试·测试工具·职场和发展
syt_biancheng1 天前
大规模考试系统性能优化与风险评估
python·功能测试·selenium·性能优化·postman