2017-03-17 22 views
0

使用phantom js執行無頭測試時,我得到如此多的紅色不必要日誌。使用幻像js和硒進行無頭測試中的必要日誌

如何刪除所有這些紅色原木 red colour info messages

public class Utility 
{ 
    private static WebDriver driver=new PhantomJSDriver(); 
    public static WebDriver getDriver() 
    { 
     return driver; 
    } 
}  

回答

0

以下是你需要做的壓制INFO日誌的內容:

File src = new File("C:\\Utility\\phantomjs-2.1.1-windows\\bin\\phantomjs.exe"); 
System.setProperty("phantomjs.binary.path", src.getAbsolutePath()); 

DesiredCapabilities dcap = new DesiredCapabilities(); 
String[] phantomArgs = new String[] { 
    "--webdriver-loglevel=NONE" 
}; 
dcap.setCapability(PhantomJSDriverService.PHANTOMJS_CLI_ARGS, phantomArgs); 
PhantomJSDriver driver = new PhantomJSDriver(dcap); 

driver.get("https://www.facebook.com/"); 

讓我知道它是否適合你。

+0

@heardm如果此答案迎合您的查詢,您可以接受此答案作爲您的問題的解決方案嗎?謝謝。 – DebanjanB

+0

我的程序沒有任何主要方法。所以它是拋出錯誤。在哪裏寫代碼 – heardm

+0

@heardm你可以使用任何你想要的代碼。如果你正在使用TestNG,你可以把代碼放在測試下的任何方法或類似的註解中。用你的確切要求提出一個新問題我很樂意幫助你。謝謝 – DebanjanB