我想禁用 chrome 通知。我知道下面的代码有效,但是 driver = new ChromeDriver(ops) 调用了一个新的浏览器窗口,但是....
ChromeOptions ops = new ChromeOptions();
ops.addArguments("--disable-notifications");
System.setProperty("webdriver.chrome.driver", "./lib/chromedriver");
driver = new ChromeDriver(ops);
...我下面的基类已经调用了一个浏览器窗口:
@Override
@Parameters({"baseUrl","seleniumUrl", "browser"})
@BeforeMethod
public void onTestSetup(String baseUrl, String seleniumUrl, String browser, ITestContext ctx, Method method)
{
super.onTestSetup(baseUrl, seleniumUrl, browser, ctx, method);
settings = new Settings();
driver.manage().timeouts().implicitlyWait(20, TimeUnit.SECONDS);
driver.manage().timeouts().setScriptTimeout(20, TimeUnit.SECONDS);
homeob = PageFactory.initElements(driver, HomePgObj.class);
}
public synchronized void loginApp(String user, String pwd) throws InterruptedException
{
homeob = PageFactory.initElements(driver, HomePgObj.class);
homeob.login(user, pwd);
}
所以这里使用 ChromeOptions 的问题打开了第二个浏览器窗口。我该如何解决这个问题?