java - Selenium Java - 在不从 chrome 选项调用浏览器的情况下禁用通知
问题描述
我想禁用 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 的问题打开了第二个浏览器窗口。我该如何解决这个问题?
解决方案
推荐阅读
- spring-boot - 如何使用 h2 数据库和 yaml 属性将 flyway 引入 spring-boot 项目?
- ios - swiftUI中scrollView的填充高度
- javascript - 如何根据屏幕大小动态设置div的宽度?
- dart - 当我更改另一个表时影响一个表
- query-string - 使用带有引号的查询字符串进行 EWS 搜索不适用于 Exchange 2016
- python - 在熊猫中使用正则表达式从多个括号中提取字符串
- javascript - 当背景图像为空时回退背景颜色
- docker - Cloud Run 上的容器内存管理和 OOM
- python - 在 Keras 中实现后期融合
- android - 进程意外退出,AAPT2错误