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 小时前
使用python读取json数据,简单的处理成元组数组
开发语言·python·测试工具·json
baynk12 小时前
wireshark的常用用法
网络·测试工具·wireshark·ctf
维度软件库12 小时前
集中打印和转换Office 批量打印精灵:Word/Excel/PDF 全兼容,效率翻倍
测试工具·电脑·开源软件
测试老哥2 天前
Jmeter+ant+jenkins接口自动化测试框架
自动化测试·软件测试·python·测试工具·jmeter·jenkins·压力测试
技术猿188702783512 天前
实现“micro 关键字搜索全覆盖商品”并通过 API 接口提供实时数据(一个方法)
开发语言·网络·python·深度学习·测试工具
格鸰爱童话3 天前
python+selenium UI自动化初探
python·selenium·自动化
autobaba3 天前
编写bat文件自动打开chrome浏览器,并通过selenium抓取浏览器操作chrome
chrome·python·selenium·rpa
计算机毕设定制辅导-无忧学长4 天前
Modbus 开发工具实战:ModScan32 与 Wireshark 抓包分析(一
网络·测试工具·wireshark
有谁看见我的剑了?4 天前
iperf3 网络带宽测试工具学习
学习·测试工具
q567315234 天前
Selenium动态网页爬虫编写与解释
爬虫·selenium·测试工具