尝试使用自定义配置文件运行时,Selenium ChromeDriver崩溃

时间:2018-12-03 12:38:51

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

我在项目的根目录中有一个复制的用户配置文件文件夹。这是我的代码:

System.setProperty("webdriver.chrome.driver", "chromedriver");
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=");
options.addArguments("--profile-directory=Profile 1");
options.addArguments("no-sandbox");
ChromeDriver driver = new ChromeDriver(options);

在此代码的最后一行,发生异常“ WebDriverException:未知错误:Chrome无法启动:异常退出” 。我真的很想找到解决方案,因为我需要Chrome浏览器与此配置文件中的特定用户一起运行,以避免几乎无限的Google入侵。有任何想法吗?

这是完整的异常输出:

Starting ChromeDriver 2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634) on port 26748
Only local connections are allowed.
Created new window in existing browser session.
Exception in thread "AWT-EventQueue-0" org.openqa.selenium.WebDriverException: unknown error: Chrome failed to start: exited abnormally
  (unknown error: DevToolsActivePort file doesn't exist)
  (The process started from chrome location /usr/bin/google-chrome is no longer running, so ChromeDriver is assuming that Chrome has crashed.)
  (Driver info: chromedriver=2.44.609551 (5d576e9a44fe4c5b6a07e568f1ebc753f1214634),platform=Linux 4.15.0-39-generic x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 528 milliseconds
Build info: version: '3.141.59', revision: 'e82be7d358', time: '2018-11-14T08:17:03'
System info: host: 'denis-TM1604', ip: '127.0.1.1', os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-39-generic', java.version: '1.8.0_191'
Driver info: driver.version: 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:214)
  at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:166)
  at org.openqa.selenium.remote.JsonWireProtocolResponse.lambda$errorHandler$0(JsonWireProtocolResponse.java:54)
  at org.openqa.selenium.remote.HandshakeResponse.lambda$getResponseFunction$0(HandshakeResponse.java:30)
  at org.openqa.selenium.remote.ProtocolHandshake.lambda$createSession$0(ProtocolHandshake.java:126)
  at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
  at java.util.Spliterators$ArraySpliterator.tryAdvance(Spliterators.java:958)
  at java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:126)
  at java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:498)
  at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:485)
  at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
  at java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:152)
  at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
  at java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:464)
  at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:128)
  at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:74)
  at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:136)
  at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:83)
  at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:552)
  at org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:213)
  at org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:131)
  at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:181)
  at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:168)
  at org.openqa.selenium.chrome.ChromeDriver.<init>(ChromeDriver.java:157)
  at supreme.SupremeWebService.run(SupremeWebService.java:32)
  at gui.AppWindow.lambda$new$0(AppWindow.java:80)
  at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2022)
  at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2348)
  at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
  at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
  at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
  at java.awt.Component.processMouseEvent(Component.java:6539)
  at javax.swing.JComponent.processMouseEvent(JComponent.java:3324)
  at java.awt.Component.processEvent(Component.java:6304)
  at java.awt.Container.processEvent(Container.java:2239)
  at java.awt.Component.dispatchEventImpl(Component.java:4889)
  at java.awt.Container.dispatchEventImpl(Container.java:2297)
  at java.awt.Component.dispatchEvent(Component.java:4711)
  at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4904)
  at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4535)
  at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4476)
  at java.awt.Container.dispatchEventImpl(Container.java:2283)
  at java.awt.Window.dispatchEventImpl(Window.java:2746)
  at java.awt.Component.dispatchEvent(Component.java:4711)
  at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:760)
  at java.awt.EventQueue.access$500(EventQueue.java:97)
  at java.awt.EventQueue$3.run(EventQueue.java:709)
  at java.awt.EventQueue$3.run(EventQueue.java:703)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:84)
  at java.awt.EventQueue$4.run(EventQueue.java:733)
  at java.awt.EventQueue$4.run(EventQueue.java:731)
  at java.security.AccessController.doPrivileged(Native Method)
  at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
  at java.awt.EventQueue.dispatchEvent(EventQueue.java:730)
  at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
  at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
  at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
  at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
  at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

0 个答案:

没有答案