赞
踩
2023-02-08 17:22:05.254 ERROR 38295 --- [io-21233-exec-2] com.cqnews.server.HotMessageServer:截图失败:org.openqa.selenium.WebDriverException: unknown error: DevToolsActivePort file doesn't exist
Build info: version: 'unknown', revision: 'unknown', time: 'unknown'
System info: host: 'cqsrd-dsjpthtfw', ip: '172.16.12.9', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-957.el7.x86_64', java.version: '1.8.0_241'
Driver info: driver.version: ChromeDriver
remote stacktrace: #0 0x55745d7d3303 <unknown>
使用root安装的chrome,系统使用selenium打开chrome时,需要设置参数,使其在root权限下使用
//设置为 headless 模式 (必须)
chromeOptions.addArguments("--headless");
chromeOptions.addArguments("--disable-gpu");//谷歌文档提到需要加上这个属性来规避bug
chromeOptions.addArguments("--no-sandbox");// “–no - sandbox”参数是让Chrome在root权限下跑
chromeOptions.addArguments("--disable-dev-shm-usage");
chromeOptions.addArguments("lang=zh_CN.UTF-8");
chromeOptions.addArguments("window-size=1920x1080"); //指定浏览器分辨率
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。