简体   繁体   中英

Selenium Webdriverjs (javascript) with chrome

Selenium Webdriver works nicely with Chromium. But when I want to use Chrome (which I want because chrome can be installed easily in the new version that does support headless mode), then chrome never starts up.

WebDriverError: unknown error: Chrome failed to start: exited abnormally (Driver info: chromedriver=2.29.461571 (8a88bbe0775e2a23afda0ceaf2ef7ee74e822cc5),platform=Linux 4.2.8.11-1-MANJARO x86_64)

var selenium = require ('selenium-webdriver'),
By = selenium.By,
until = selenium.until,
Select = selenium.Select;

var chrome = require ("selenium-webdriver/chrome");
var o = new chrome.Options();

o.setChromeBinaryPath( "/opt/google/chrome-unstable/");

var service = new chrome.ServiceBuilder()
    .loggingTo('/tmp/chromescraper.txt')
    .enableVerboseLogging()
    .build();

var driver = chrome.Driver.createSession(o, service);

 driver.get ("http://news.google.com");

Any ideas?

I ran into the same issue and what I found out is each ChromeDriver supports certain Chrome binary version. If they don't match, you might run into issues. For example, the current latest ChromeDriver below at the time of this writing is 2.33 will support Chrome v60-62. If you go to the site below and find on your ChromeDriver version, it should tell you which Chrome version it supports. Good luck!

https://sites.google.com/a/chromium.org/chromedriver/downloads

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM