2
package Demo;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class Demo {
public static void main(String[] args) {
String userProfile = "C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe";
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=" + userProfile);
options.addArguments("--start-maximized");
System.setProperty("webdriver.chrome.driver", "C:\\Users\\Abhishek.Dalakoti\\workspace\\HomeShopDemo\\Chromedriver.exe");
WebDriver driver = new ChromeDriver(options);
driver.get("http://www.google.com");
//driver.findElement(By.xpath("//*input[@type='text']")).sendKeys("dell");
}
}
這是我運行上述時得到的錯誤。有沒有人解決這個問題本地連接問題硒驅動程序與鉻驅動器
我試過改變Selenium和ChromeDriver版本的版本,但沒有任何工作。
Exception in thread "main" org.openqa.selenium.WebDriverException: unknown error: cannot create default profile directory
(Driver info: chromedriver=2.19.346078 (6f1f0cde889532d48ce8242342d0b84f94b114a1),platform=Windows NT 6.1 SP1 x86_64)
(WARNING: The server did not provide any stacktrace information)
Command duration or timeout: 750 milliseconds
Build info: version: '2.52.0', revision: '4c2593c', time: '2016-02-11 19:03:33'
System info: host: 'HSNMM-AbhishekD', ip: '10.50.33.160', os.name: 'Windows 7', os.arch: 'amd64', os.version: '6.1', java.version: '1.8.0_73'
Driver info: org.openqa.selenium.chrome.ChromeDriver
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: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:148)
at Demo.Demo.main(Demo.java:16)
檢查此鏈接: http://stackoverflow.com/questions/14480717/load-chrome-profile-using-selenium-webdriver – noor
已經嘗試它不工作。 –
嘗試加入: System.setProperty(「webdriver.chrome.driver」,「C:\\ chromedriver.exe」); – noor