Java 如何使用selenium/TestNg禁用chrome浏览器的web安全性
我想在我的代码中使用以下命令Java 如何使用selenium/TestNg禁用chrome浏览器的web安全性,java,google-chrome,selenium,selenium-webdriver,selenium-chromedriver,Java,Google Chrome,Selenium,Selenium Webdriver,Selenium Chromedriver,我想在我的代码中使用以下命令selenium/testng,因为每次执行代码时,都会由webdriver创建一个新的浏览器实例,其中默认启用了安全性 chrome.exe --disable-web-security 尝试以下操作,根据您的规范更改路径和斜线:- WebDriver driver=null; System.setProperty("webdriver.chrome.driver","./src//lib//chromedriver
selenium/testng
,因为每次执行代码时,都会由webdriver
创建一个新的浏览器实例,其中默认启用了安全性
chrome.exe --disable-web-security
尝试以下操作,根据您的规范更改路径和斜线:-
WebDriver driver=null;
System.setProperty("webdriver.chrome.driver","./src//lib//chromedriver");
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
ChromeOptions options = new ChromeOptions();
options.addArguments("test-type");
options.addArgument("--start-maximized");
options.addArguments("--disable-web-security");
options.addArguments("--allow-running-insecure-content");
capabilities.setCapability("chrome.binary","./src//lib//chromedriver");
capabilities.setCapability(ChromeOptions.CAPABILITY, options);
driver = new ChromeDriver(capabilities);
driver.get("https://www.google.com/");
下面是列出所有可用chrome标志的链接:-
希望它能帮助您:)我仍然无法使用禁用web安全模式打开url。。是否可以使用selenium测试桌面应用程序?不,无法使用selenium测试桌面应用程序。我已更新了答案。您能再试一次吗?我刚刚在ChromrDriver Const中通过了选项,现在可以使用了。非常感谢。。驱动程序=新的色度驱动程序(可选);哎呀!!还有一件事要说。。不传递选项,而传递功能。。。功能本身包含选项参数。。。再次更新我的答案