好了,终于明白了:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
# enable browser logging
d = DesiredCapabilities.CHROME
d['loggingPrefs'] = { 'browser':'ALL' }
driver = webdriver.Chrome(desired_capabilities=d)
# load the desired webpage
driver.get('http://foo.com')
# print messages
for entry in driver.get_log('browser'):
print(entry)
source
字段相等的条目'console-api'
对应于控制台消息,消息本身存储在该message
字段中。
从chromedriver 75.0.3770.8开始,您必须使用goog:loggingPrefs而不是loggingPrefs:
d['goog:loggingPrefs'] = { 'browser':'ALL' }