【发布时间】:2019-03-12 12:07:43
【问题描述】:
在使用 Selenium Webdriver 进行测试时,我试图阻止 Chrome 通知。我曾尝试使用网站上其他地方记录的 Java 命令,但每次尝试添加时,我的附加代码都会被标记为错误。
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
/**
* @author Me
*/
public class MyTest {
static WebDriver webDriver;
/**
* @param args
* @throws InterruptedException
*/
public static void main(final String[] args) throws InterruptedException {
// Telling the system where to find the chrome driver
System.setProperty(
"webdriver.chrome.driver",
"C:/Users/Me/Documents/WebDriver/chromedriver_win32/chromedriver.exe");
// Open the Chrome browser
webDriver = new ChromeDriver();
webDriver.manage().window().maximize();
我正在尝试将以下命令添加到我的代码中,但它们不起作用:
ChromeOptions ops = new ChromeOptions();
ops.addArguments("--disable-notifications");
谁能告诉我需要在哪里将它们添加到我的代码 sn-p 中?我尝试将它们插入到 System.setProperty 上方,但它不起作用。
【问题讨论】:
标签: java google-chrome selenium-webdriver webdriver selenium-chromedriver