Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selenium chromedriver unknown error while running chrome 59 headless with browsermob proxy

I wrote a simple Selenium test (opening a page) of a secured site in a headless mode using Chrome 59 beta version.

I'm getting an the following exception while executing my code. The exception is thrown while initializing the driver

When I rerun my script after commenting the headless option (options.addArguments("headless")) it shows Chrome and running fine but my objective is to run it as headless. Could you please provide your thoughts on resolving my problem?

Exception: Starting ChromeDriver 2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b) on port 4971 Only local connections are allowed. Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.29.461585 (0be2cd95f834e9ee7c46bcc7cf405b483f5ae83b),platform=Mac OS X 10.12.2 x86_64) (WARNING: The server did not provide any stacktrace information) Command duration or timeout: 60.14 seconds Build info: version: '3.4.0', revision: 'unknown', time: 'unknown'

Here are the steps: I'm using Scala with SBT on Mac. Chrome 59 beta version ChromeDrive 2.29 release version.

Added the following dependencies

  • "org.seleniumhq.selenium" % "selenium-chrome-driver" % "3.4.0"
  • "org.seleniumhq.selenium" % "selenium-support" % "3.4.0"
  • "net.lightbody.bmp" % "browsermob-core" % "2.1.4"

Scala Code:

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()
like image 446
user7999303 Avatar asked Oct 18 '22 12:10

user7999303


1 Answers

According to the 2.29 webdriver notes page, It says that

----------ChromeDriver v2.29 (2017-04-04)----------

Supports Chrome v56-58

so u have to downgrade your chrome version to be compatible with the latest chrome webdriver.

source: https://chromedriver.storage.googleapis.com/2.29/notes.txt

like image 102
IslamTaha Avatar answered Oct 21 '22 06:10

IslamTaha