我正在边缘浏览器上运行自动化。 Edge 浏览器支持配置文件,每当我从 webdriver 启动 Edge 时,它都会创建新的配置文件。有什么方法可以设置选项以使用给定的用户配置文件启动边缘?
我以Java语言为例。你可以使用user-data-dir
and profile-directory
使用特定配置文件通过 Selenium 启动 Edge。示例代码如下:
System.setProperty("webdriver.edge.driver", "your\\path\\to\\edge\\webdriver\\msedgedriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
// Here you set the path of the profile ending with User Data not the profile folder
edgeOptions.addArguments("user-data-dir=C:\\Users\\username\\AppData\\Local\\Microsoft\\Edge\\User Data");
// Here you specify the actual profile folder
edgeOptions.addArguments("profile-directory=Profile 2");
edgeOptions.addArguments("--start-maximized");
WebDriver driver = new EdgeDriver(edgeOptions);
driver.get("https://www.google.com");
Note:将代码中的路径更改为您自己的路径。
如果您不知道具体配置文件的路径,您可以检查edge://version/
像下面这样:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)