google-chrome - 是否可以使用 Google Chrome 而不是 chromedriver with selenium?

标签 google-chrome selenium automation webdriver two-factor-authentication

有没有办法使用标准的 chrome 实例而不是 chromedrive.exe 和 selenium?

专为 selenium 设计的 chrome 驱动程序在初始化时不保存 cookie 或浏览器状态。

例如,已安装的 chrome 实例能够绕过 2 因素身份验证,因为它可以记住它是远程系统中的已知设备。另一方面,selenium chrome 驱动程序无法绕过 2-factor auth,因为它不记得它是一个已知设备。

我想使用已安装的 Google Chrome,而不是带有 selenium 网络驱动程序的 chromedriver.exe。这能做到吗?

最佳答案

您必须在 ChromeOptions 中添加感兴趣的配置文件路径。

  • 打开您的 Chrome 浏览器并转到 chrome://version/ 页面。
  • 并获取配置文件路径。

例如,对我来说:

enter image description here

因此,在 Java 中:

        String chromeDriver = "/pathTo/chromedriver";
        System.setProperty("webdriver.chrome.driver", chromeDriver);

        ChromeOptions options = new ChromeOptions();
        String dir= "/Volumes/Macintosh HD/Users/DurdenP/Library/Application Support/Google/Chrome/";
        options.addArguments("user-data-dir="+dir);
        ChromeDriver driver = new ChromeDriver(options);

关于google-chrome - 是否可以使用 Google Chrome 而不是 chromedriver with selenium?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47105295/

相关文章:

javascript - 在 Chrome 中弹出期间不会出现蓝色菜单

html - 为什么显示 "inline"在 Mac 和 Windows 中的工作方式不同

javascript - 从扩展内获取 localStorage 而不加载页面

maven - 如何正确配置 Selenium Maven 插件以与 Xvfb 一起运行以 headless 运行

用于方便记录器的 println 用法的 Java 翻译器

swift - UITesting Xcode 7 : How to tell if XCUIElement is visible?

com - 如何把WebBrowser 控件纳入IE9 标准?

html - Chrome 存储新密码但不将其链接到当前用户名 : how can I fix it?

javascript - Python 使用 Selenium : access iframe whose src is returned by javascript function

java - 使用selenium webdriver执行maven项目时获取 "Null pointer exception"