【发布时间】:2021-07-07 11:17:18
【问题描述】:
您好,我正在尝试在 selenium 中为我的驱动程序添加一些设置,但似乎可以使它们正常工作。
我正在尝试添加
{
"DEVELOPER_MODE":false,
"AUTOMATION_MODE":true,
"AUTOMATION_LAUNCH_URL":"{whatever_url_you_want_to_test_with}"
}
到我的驱动文件
public static WebDriver startDriverTwo() {
String projectLocation = System.getProperty("user.dir");
System.setProperty("webdriver.chrome.driver", projectLocation + "/chromedriver.exe");
ChromeOptions opt = new ChromeOptions();
opt.addArguments("start-maximized");
opt.addArguments("disable-infobars");
opt.addArguments("--disable-extensions");
opt.addArguments("--window-size=1920x1080");
opt.addArguments("--disable-cache");
//options.addArguments("--headless");
opt.addArguments("--disable-application-cache");
opt.addArguments("--disk-cache-size=0");
opt.addArguments("--disable-gpu"); // applicable to windows os only
opt.addArguments("--disable-dev-shm-usage"); // overcome limited resource problems
opt.addArguments("--dns-prefetch-disable");
opt.addArguments("--disable-notifications");
opt.addArguments("disable-infobars")
//Enter the path of your Electron app
opt.setBinary("pathtoelectronapp.exe");
driver = new ChromeDriver(opt);
System.out.println("opening app");
return driver;
}
我试过了
setExperimentalOption()
setProperty()
但这些都不起作用?知道我该如何处理这些吗?
【问题讨论】:
标签: java selenium selenium-webdriver testing selenium-chromedriver