使用MAC系统时无法从硒中启动铬

时间:2018-02-13 06:32:51

标签: java google-chrome selenium selenium-webdriver selenium-chromedriver

MAC:10.11.6, 硒:2.53(也试用3.4和3.8)& Java 1.8

尝试了驱动程序设置:

String exePath ="/usr/local/Cellar/chromedriver/2.35/bin/chromedriver";
System.setProperty("webdriver.chrome.driver", exePath);
WebDriver driver = new ChromeDriver();
driver = new ChromeDriver(options);

错误堆栈跟踪:

Starting ChromeDriver 2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef) on port 14988
Only local connections are allowed.
Exception in thread "main" org.openqa.selenium.SessionNotCreatedException: session not created exception
from disconnected: unable to connect to renderer
  (Session info: chrome=64.0.3282.140)
  (Driver info: chromedriver=2.35.528157 (4429ca2590d6988c0745c24c8858745aaaec01ef),platform=Mac OS X 10.11.6 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 2.55 seconds
Build info: version: '2.53.1', revision: 'a36b8b1', time: '2016-06-30 17:32:46'
System info: host: '01hw382197', ip: '172.25.155.171', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.11.6', java.version: '1.8.0_111'
Driver info: org.openqa.selenium.chrome.ChromeDriver
    at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
    at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:206)
    at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:158)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:678)
    at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:249)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
    at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:170)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:159)
    at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:116)
    at dataAndConfig.DriverClass.getDriver(DriverClass.java:39)
    at scriptsPostPaidWebApp.BillingPayNow.main(BillingPayNow.java:27)

1 个答案:

答案 0 :(得分:0)

查看以下链接:

  1. https://github.com/SeleniumHQ/selenium/issues/4897
  2. WebDriverError: disconnected: unable to connect to renderer
  3. https://github.com/SeleniumHQ/selenium/issues/4979
  4. 首先,您应确保ChromeDriver支持您的Chrome版本。由于您使用的是ChromeDriver 2.3.5和Google Chrome v64,因此您应该没问题。 (您仍然可能希望升级Selenium版本)

    根据上面发布的链接,您需要注释掉以任何方式操纵浏览器窗​​口大小的每种方法。例如setMaximize()

    如果这不起作用,您可能需要尝试options.addArguments("no-sandbox");