selenium - Microsoft Edge WebDriver - 无法为自动化使用默认应用数据配置文件 - Edge Ver 80
问题描述
我必须使用现有的用户登录会话,我们将需要 EDGE 用户配置文件,因为我们观察到 EDGE 驱动程序不使用现有的用户数据配置文件,它每次都会创建一个新的配置文件
EDGE 默认配置文件路径
C:\Users\edge2automation\AppData\Local\Microsoft\Edge\User Data\Default
(边缘驱动程序)路径 -
C:\Users\edge2automation\AppData\Local\Temp\scoped_dir64860_1277252271\Default
解决方案
由于新的Edge是基于Chromium的,我们可以参考使用Chrome profile的解决方案,将关键词改为Edge:
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.edge.EdgeOptions;
public class Edgeauto {
public static void main(String[] args) {
System.setProperty("webdriver.edge.driver", "your\\path\\to\\edge\\webdriver\\msedgedriver.exe");
EdgeOptions edgeOptions = new EdgeOptions();
edgeOptions.addArguments("user-data-dir=C:\\Users\\edge2automation\\AppData\\Local\\Microsoft\\Edge\\User Data");
edgeOptions.addArguments("--start-maximized");
WebDriver driver = new EdgeDriver(edgeOptions);
driver.get("https://www.google.com/");
}
}
请注意,这需要使用 selenium-server-4.0.0-alpha-4,您可以在此处下载表格。
推荐阅读
- swift - Alamofire 5,如何停止所有请求,刷新访问令牌并重新运行所有停止的请求?
- reactjs - 如何仅在渲染时在 React 组件中导入 SCSS 文件?
- python - 将嵌套字典和列表转换为 JSON 的问题
- javascript - 用玩笑模拟条件 window.open 函数调用
- python - 过滤 Pandas DataFrame 中的特定值
- angular - 将 *ngFor 动态添加到 HTML 元素
- python-3.x - 使用 tf-coreml 将 Tensorflow 转换为 CoreML
- java - Spring boot 2 embed tomcat 9.0.26 无法加载jks文件流关闭
- ruby-on-rails - 通过 created_at 对关联模型进行分组和计数
- c++ - 如何简化模板模板参数中的 enable_if 别名