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);
	
相关推荐
愈努力俞幸运2 天前
python selenium 用法教程
python·selenium
Future_yzx2 天前
Selenium 浏览器操作与使用技巧——详细解析(Java版)
java·selenium·测试工具
Algorithm-0073 天前
【Postman 接口测试】接口用例设计与评审
测试工具·postman
武陵悭臾3 天前
网络爬虫学习:应用selenium获取Edge浏览器版本号,自动下载对应版本msedgedriver,确保Edge浏览器顺利打开。
学习·selenium·edge·deepseek·winreg·zipfile
Future_yzx4 天前
selenium自动化测试框架——面试题整理
java·selenium·intellij-idea
hunter2062064 天前
ubuntu无法上网的解决办法
网络·测试工具·ubuntu
代码的乐趣4 天前
支持selenium的chrome driver更新到132.0.6834.110
chrome·python·selenium
霍格沃兹测试开发学社测试人社区4 天前
性能测试丨JVM 性能数据采集
软件测试·jvm·测试开发·测试工具
Algorithm-0074 天前
【Postman接口测试】Postman的全局变量和环境变量设置
测试工具·postman
安冬的码畜日常4 天前
【玩转 Postman 接口测试与开发2_009】第八章:利用 Postman 的 Flows 模块实现工作流测试(Workflow Testing)
测试工具·接口测试·postman·workflow·api接口·postman flows·工作流测试