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);
	
相关推荐
demodeom9 小时前
常见浏览器 WebDriver 驱动下载
selenium·webdriver
爱学习的大牛12311 小时前
Linux 内核开发/测试工具对比 Windows 驱动验证工具 (Driver Verifier)
linux·测试工具·内核
私人珍藏库1 天前
[Windows] Wireshark 网络抓包工具 v4.4.6
网络·测试工具·wireshark
高耳机High-Earphone2 天前
多人五子棋联机对战平台 测试报告
自动化测试·selenium·性能测试·ssm项目·五子棋对战·项目测试·梯度压力测试
徐同保2 天前
fetch使用put请求提交文件,postman使用put请求提交文件
测试工具·lua·postman
2401_897930063 天前
Selenium 入门介绍
selenium·测试工具
雨中夜归人4 天前
自动化测试工具playwright中文文档-------14.Chrome 插件
python·测试工具·自动化·pytest·playwright
SoFlu软件机器人4 天前
JVM 调优不再难:AI 工具自动生成内存优化方案
jvm·测试工具·压力测试
network_tester4 天前
是德科技E5080B网络分析仪深度评测:5G/车载雷达测试实战指南
网络·科技·测试工具·5g·硬件架构·信号处理·射频工程
码到成功>_<4 天前
postman使用技巧
测试工具·lua·postman