use*_*303 5 beta headless selenium-chromedriver browsermob-proxy
我使用Chrome 59 beta版以无头模式编写了一个简单的安全测试网站的Selenium测试(打开页面)。
执行代码时出现以下异常。初始化驱动程序时抛出异常
当我在注释无头选项(options.addArguments(“ headless”))后重新运行脚本时,它显示Chrome并运行良好,但我的目标是以无头方式运行它。您能否提供解决我的问题的想法?
例外:在端口4971上启动ChromeDriver 2.29.461585(0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b)仅允许本地连接。线程“主” org.openqa.selenium.WebDriverException中的异常:未知错误:Chrome无法启动:异常退出(驱动程序信息:chromedriver = 2.29.461585(0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),平台= Mac OS X 10.12.2 x86_64)(警告:服务器未提供任何堆栈跟踪信息)命令持续时间或超时:60.14秒构建信息:版本:'3.4.0',修订版:'未知',时间:'未知'
步骤如下:在Mac上,我将Scala与SBT一起使用。Chrome 59 beta版ChromeDrive 2.29发布版本。
添加了以下依赖
Scala代码:
val username = "username"
val password = "password"
val domainname = "yoursecuredomain.com"
val browserMobProxyServer = new BrowserMobProxyServer()
browserMobProxyServer.start(0)
browserMobProxyServer.autoAuthorization(domainname, username, password, AuthType.BASIC)
val seleniumProxy = ClientUtil.createSeleniumProxy(browserMobProxyServer)
val options = new ChromeOptions()
options.addArguments("headless")
options.addArguments("--disable-gpu")
options.setBinary("""/Applications/Google Chrome.app/Contents/MacOS/Google Chrome""")
val desiredCapabilities = new DesiredCapabilities()
desiredCapabilities.setCapability(ChromeOptions.CAPABILITY, options)
desiredCapabilities.setCapability(CapabilityType.PROXY, seleniumProxy)
val driver: WebDriver = new ChromeDriver(desiredCapabilities)
val baseUrlString = s"""https://$domainname"""
driver.navigate().to(baseUrlString)
Thread.sleep(3000)
println("title: " + driver.getTitle)
driver.quit()
browserMobProxyServer.abort()
Run Code Online (Sandbox Code Playgroud)
根据 2.29 webdriver 注释页面,它说
----------ChromeDriver v2.29 (2017-04-04)------------
所以你必须降级你的 chrome 版本才能与最新的 chrome webdriver 兼容。
来源: https: //chromedriver.storage.googleapis.com/2.29/notes.txt
| 归档时间: |
|
| 查看次数: |
1493 次 |
| 最近记录: |