我正在使用以下代码加载自定义的chrome配置文件:
ChromeDriverService chSvc = new ChromeDriverService.Builder().usingDriverExecutable(new File("C://Users//kanu//Downloads//Selenium//chromedriver_win32//chromedriver.exe")).usingAnyFreePort().build();
ChromeOptions chOption = new ChromeOptions();
/**
* "user-data-dir = profilepath" --to open profile
* "--start-maximized" for maximize the browser
*/
chOption.addArguments("user-data-dir = C:/Users/kanu/AppData/Local/Google/Chrome/New User");
chOption.addArguments("--start-maximized");
WebDriver driver = new ChromeDriver(chSvc, chOption);
driver.get("https://www.google.com");
它可以运行并运行现有的chrome配置文件,但不会打开所需的URL并获得以下异常:
Starting ChromeDriver 2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9) on port 43388
Only local connections are allowed.
Mar 15, 2017 10:55:27 AM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected dialect: OSS
Exception in thread "main" org.openqa.selenium.NoSuchSessionException: no such session
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64) (WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 8 milliseconds
Build info: version: '3.3.1', revision: '5234b32', time: '2017-03-10 09:04:52 -0800'
System info: host: 'GUR-ACC093-W', ip: '100.102.83.217', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_102'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Capabilities [{message=unknown error: Chrome failed to start: crashed
(Driver info: chromedriver=2.27.440174 (e97a722caafc2d3a8b807ee115bfb307f7d2cfd9),platform=Windows NT 10.0.10586 x86_64), platform=ANY}]
Session ID: ea04006993fa5bd7530cfe75cca7ae0d
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at org.openqa.selenium.remote.ErrorHandler.createThrowable(ErrorHandler.java:216)
at org.openqa.selenium.remote.ErrorHandler.throwIfResponseFailed(ErrorHandler.java:168)
at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:638)
at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:325)
at launch.LaunchChrome.main(LaunchChrome.java:50)
任何人都可以解决这个问题吗?