是的,我们可以像调用Firefox配置文件一样通过调用保存的Chrome配置文件来做到这一点。以下是我之前做的一些步骤
在Java中,我们可以使用ChromeOptions和Chrome配置文件来实现。在chrome中,导航至chrome:// version
/,它将显示配置文件路径和可执行路径。
根据我的工作,配置文件路径为“
LocalGoogleChromeUser DataProfile3这是显示我
chrome://version/在普通chrome浏览器中导航至时显示的内容”。在此配置文件中,我导航至stackoverflow并保存了凭据。所以用下面的代码
Map<String, Object> prefs = new HashMap<String, Object>();prefs.put("binary", "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe");System.setProperty("webdriver.chrome.driver", "E:\selenium_setups\poi-3.12\chromedriver.exe");ChromeOptions options = new ChromeOptions();options.setExperimentalOption("prefs", prefs);options.addArguments("user-data-dir=C:\Users\murali\AppData\Local\Google\Chrome\User Data\Profile 3");DesiredCapabilities capabilities = DesiredCapabilities.chrome();capabilities.setCapability(ChromeOptions.CAPABILITY, options);WebDriver driver = new ChromeDriver(capabilities);//WebDriver driver = new ChromeDriver(options);driver.get("http://codingdict.com");根据我的理解,我除了将http://codingdict.com页显示为已登录外,但第一次没有登录。因此在驱动程序打开的chrome中使用chrome://
version /进行了交叉检查,配置文件路径显示为 Local Google Chrome User Data Profile 3
Default。然后手动登录到该配置文件中,它本身是由网络驱动程序打开的,并通过关闭它来执行增益。
最后,页面显示为已登录。所以它可能是在Java中,希望它可以帮助您尝试使用C#。



