根据chromedriver documentation我应该能够在记录性能时关闭页面域中的事件。我尝试过设置perfLoggingPrefs,但仍能获得页面事件。我设置正确了吗?在
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
options = webdriver.ChromeOptions()
options.add_argument("--disable-extensions")
options.add_argument("--allow-running-insecure-content")
options.add_argument("--ignore-certificate-errors")
options.add_argument("--disable-single-click-autofill")
options.add_argument("--disable-autofill-keyboard-accessory-view[8]")
options.add_argument("--disable-full-form-autofill-ios")
options.headless = True
options.add_argument('--disable-gpu')
caps = DesiredCapabilities.CHROME
caps['loggingPrefs'] = {
'browser': 'ALL',
'performance' : 'ALL',
}
caps['perfLoggingPrefs'] = {
'enableNetwork' : True,
'enablePage' : False,
'enableTimeline' : False
}
driver = webdriver.Chrome(options=options, desired_capabilities=caps)
### connect to my site, do some actions then I call
perfs = driver.get_log('performance')
for row in perfs:
print(perfs)
输出: 在
^{pr2}$我试着在字典中使用'true'和'false'字符串,而没有对捕获的日志进行任何更改。在
caps['perfLoggingPrefs'] = {
'enableNetwork' : 'true',
'enablePage' : 'false',
'enableTimeline' : 'false'
}
使用
你必须把
perfLoggingPrefs
作为色差传递,你可以通过add_experimental_option()
来传递然而,即使}事件。另一方面,过滤对
enablePage
被设置为False
,仍然会出现{enableNetwork
起作用,因此chromedriver中可能有一个bug。在您始终可以手动筛选日志,如下所示:
^{pr2}$相关问题 更多 >
编程相关推荐