简体   繁体   English

带有Chrome的Selenium Webdriverjs(javascript)

[英]Selenium Webdriverjs (javascript) with chrome

Selenium Webdriver works nicely with Chromium. Selenium Webdriver可与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. 但是,当我要使用Chrome(我希望这样做是因为可以在支持无头模式的新版本中轻松安装chrome)时,chrome永远无法启动。

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) WebDriverError:未知错误:Chrome无法启动:异常退出(驱动程序信息: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. 我遇到了同样的问题,发现每个ChromeDriver支持某些Chrome二进制版本。 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. 例如,在撰写本文时,以下当前最新的ChromeDriver为2.33,将支持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. 如果您转到下面的站点并找到您的ChromeDriver版本,它应该告诉您它支持的Chrome版本。 Good luck! 祝好运!

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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