2015-07-21 31 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