2015-07-21 33 views
-1

我使用蚂蚁运行我硒测试,我有这样的消息(参见图):Java的硒chromeDriver控制台消息错误

[JUnit的]错误
上[JUnit的]启动ChromeDriver(v2.xxxxx)端口XXXX

我尝试了以下特性,但没有成功:

options.addArguments("--disable-logging"); 
options.addArguments("--ignore-certificate-errors"); 
options.addArguments("--silent"); 

我可以禁用此消息?这是可能的 ?

+0

不要放在问题的图片,请..拿代码,并将其粘贴到这个问题 – sircapsalot

+0

究竟是你的问题有? –

+0

我可以禁用此消息吗?这是可能的 ? – dicto

回答

0

我们需要传递 - 无声参数给chromedriver停止控制台消息。我们可以做到这一点使用 'withSilent(真)' 的方法使用chromedriverservice如下面的代码示例所示

启动chromedriver

示例代码:

  ChromeDriverService cdservice=new ChromeDriverService.Builder().usingDriverExecutable(new File("/path/to/chromedriver.exe")) 
        .withLogFile(new File("/path/to/chromedriver.log")) 
        .withSilent(true) 
        .usingAnyFreePort() 
        .build(); 

      WebDriver driver = new ChromeDriver(cdservice); 
      driver.get("http://www.google.com"); 
1

我建议:

ChromeOptions chromeOptions = setupChromeOptions(); 
    System.setProperty("webdriver.chrome.logfile", "\\path\\chromedriver.log"); 
    System.setProperty("webdriver.chrome.driver", "\\path\\chromedriver.exe"); 
    System.setProperty("webdriver.chrome.args", "--disable-logging"); 
    System.setProperty("webdriver.chrome.silentOutput", "true"); 
    driver = new ChromeDriver(chromeOptions); 

因为 1)这种方式适用于我和 2)经常recdomended ChromeDriverService.Builder()为我引发一个编译错误。

这对我的作品有以下配置

selenium-chrome-driver-2.48.2.jar 
    chromedriver 2.20 
    selenium-java-2.48.2.jar