【问题标题】:is there a method or a function to hide selenium's output from the program?有没有一种方法或函数可以从程序中隐藏 selenium 的输出?
【发布时间】:2021-02-14 10:20:17
【问题描述】:
我有一些用 python 编写的 selenium 代码,但问题是 selenium 总是在程序开始时打印出这个输出
DevTools listening on ws://ip address/devtools/browser/some numbers
由于我的电脑不支持蓝牙,我也得到了这个输出:
[10376:9472:1101/171134.942:ERROR:device_event_log_impl.cc(208)] [17:11:34.941] Bluetooth: bluetooth_adapter_winrt.cc:1076 Getting Default Adapter failed.
有没有办法只消除硒的输出?
【问题讨论】:
标签:
python
python-3.x
selenium
output
【解决方案1】:
我使用在 SO here 上找到的以下内容
options = webdriver.ChromeOptions()
# disable some annoying debug output to console
options.add_argument('--log-level=3')
options.add_experimental_option('excludeSwitches', ['enable-logging'])
browser = webdriver.Chrome(
"C://Program Files (x86)//Google//Chrome//Application//chromedriver.exe", options=options)
【解决方案2】:
我认为如果你将这个添加到你的代码中/将你的代码更改为这个,它应该可以解决它
driver = webdriver.Chrome(service_log_path=os.devnull)
它应该告诉 selenium,你不想在日志中放任何东西