给定以下代码片段:
case "CHROME":
System.setProperty("webdriver.chrome.driver", DriverPaths.CHROMEPATH);
ChromeOptions options = new ChromeOptions();
options.addArguments("disable-infobars");
options.addArguments("--disable-extensions");
options.addArguments("--disable-notifications");
options.addArguments("--start-maximized");
options.addArguments("--disable-web-security");
options.addArguments("--no-proxy-server");
options.addArguments("--enable-automation");
options.addArguments("--disable-save-password-bubble");
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("credentials_enable_service", false);
prefs.put("profile.password_manager_enabled", false);
options.setExperimentalOption("prefs", prefs);
return new ChromeDriver();
有什么想法吗?
最佳答案
您将必须使用以下命令: options 是你的 chrome 选项。
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
WebDriver driver = new ChromeDriver(capabilities);
通过将功能传递给 chrome 驱动程序,它们将被加载到 chrome 中。
DesiredCapabilities.chrome();
将选择正确的浏览器,在本例中为 Chrome。
关于selenium - 为 WebDriver 测试禁用 Google Chrome 密码气泡,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43342732/