如果您的用 例 是禁用 通知,则可以使用 以下选项:
System.setProperty("webdriver.gecko.driver", "C:\\path\\to\\geckodriver.exe");
ProfilesIni profile = new ProfilesIni(); FirefoxProfile testprofile = profile.getProfile(“debanjan”); testprofile.setPreference(“dom.webnotifications.enabled”, false); testprofile.setPreference(“dom.push.enabled”, false); DesiredCapabilities dc = DesiredCapabilities.firefox(); dc.setCapability(FirefoxDriver.PROFILE, testprofile); FirefoxOptions opt = new FirefoxOptions(); opt.merge(dc); WebDriver driver = new FirefoxDriver(opt); driver.get("https://www.ndtv.com/”);
:此方法使用存储在我的本地系统中的现有FirefoxProfile
名称为 的现有文件,该文件是 上 文件中的文档
System.setProperty("webdriver.chrome.driver", "C:\\path\\to\\chromedriver.exe");
Map