本文介紹了如何使用 Selenium 和 Python 綁定禁用日志記錄的處理方法,對大家解決問題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!
問題描述
簡單問題:在 Python 綁定中使用 Selenium 時(shí)如何完全禁用日志記錄,前代碼如下:
Simple question: how to completely disable logging when using Selenium from Python bindings, ex code as follows:
browser = webdriver.Chrome()
我嘗試過類似的方法:
options = webdriver.ChromeOptions();
options.add_argument('--log-level 3')
browser = webdriver.Chrome(chrome_options=options)
甚至:
options = webdriver.ChromeOptions();
options.add_argument('--disable-logging')
browser = webdriver.Chrome(chrome_options=options)
但文件chromedriver.log"仍然出現(xiàn)在每次新的測試運(yùn)行中.
but still the file 'chromedriver.log' is appearing on each new run of the tests.
推薦答案
源代碼,顯示了一個(gè)名為 service_log_path
的選項(xiàng)的存在.
The source code of Chrome's webdriver, shows the existence of an option called service_log_path
.
所以如果你想擺脫文件,你可以設(shè)置這個(gè)屬性為
So if you want to get rid of the file, you could set this property to
/dev/null
如果你在 Linux/Unix 下運(yùn)行;NUL
windows下
/dev/null
if you are running under Linux/Unix ;NUL
under windows
希望對你有幫助
這篇關(guān)于如何使用 Selenium 和 Python 綁定禁用日志記錄的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!