mkk*_*wat 5 c# java selenium selenium-webdriver
当您使用 Selenium 启动 Web 驱动程序时,它会打开相应 Web 浏览器的一个全新且非常新鲜的实例(看起来好像刚刚安装,没有历史记录和默认设置}。
有什么方法可以打开通常的窗口,这些窗口将具有我在 chrome 或 Firefox 中完成的自定义设置,例如附加组件等等?
您可以使用 FireFox 中的现有配置文件
File profileDir = new File("Path to default profile")
FirefoxProfile firefoxProfile = new FirefoxProfile(profileDir);
WebDriver webDriver = new FirefoxDriver(firefoxProfile);
Run Code Online (Sandbox Code Playgroud)
对于 Chrome,您可以使用以下选项:
ChromeOptions options = new ChromeOptions();
options.addArguments("user-data-dir=C:/Users/user_name/AppData/Local/Google/Chrome/User Data");
driver = new ChromeDriver(options);
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1621 次 |
最近记录: |