相关疑难解决方法(0)

使用Java使用Selenium WebDriver加载Chrome配置文件

我遇到了一些让Selenium加载镀铬配置文件的麻烦.

String pathToChrome = "driver/chromedriver.exe";
System.setProperty("webdriver.chrome.driver", pathToChrome);

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
String chromeProfile = "C:\\Users\\Tiuz\\AppData\\Local\\Google\\Chrome\\User Data\\Default";
ArrayList<String> switches = new ArrayList<String>();
switches.add("--user-data-dir=" + chromeProfile);
capabilities.setCapability("chrome.switches", switches);
WebDriver driver = new ChromeDriver(capabilities);
driver.get("http://www.google.com");
Run Code Online (Sandbox Code Playgroud)

它开始很好并且工作得很完美,但是我想要加载默认配置文件,因为我想测试它,启用了一些Extensions并测试了一些首选项.

有没有人知道为什么这段代码不起作用?

我在Windows 7 x64上用Selenium 2.29.1和2.28.0以及chromedriver 26.0.1383.0测试了它.

java profile google-chrome selenium-webdriver

15
推荐指数
5
解决办法
7万
查看次数

无法使用Selenium WebDriver在Chrome中加载默认配置文件

我正在使用Selenium WebDriver在需要http身份验证的页面上执行某些操作。

我已经登录了我的默认配置文件。但是硒chromedriver会为每次使用自动使用新的配置文件,因此我无法通过身份验证阶段。

因此,我正在考虑在Selenium WebDriver for Chrome上使用我的默认配置文件(具有帐户登录权限)。

即使我使用以下代码,默认配置文件似乎也没有加载到Chrome中

ChromeOptions options = new ChromeOptions();

options.AddArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data/Default");   


IWebDriver driver = new ChromeDriver(@"C:\Users\Lawrence\Desktop\selenium-dotnet-2.33.0\net40",options);
Run Code Online (Sandbox Code Playgroud)

有什么帮助吗?=)

c# selenium selenium-chromedriver selenium-webdriver

4
推荐指数
1
解决办法
5481
查看次数