Currently i am trying to use chromedriver with enable log performance for tracking front end performance, and i have issue when config trace categories with option 'disabled-by-default-devtools.screenshot', i can not see this log information in my performance log and i am very appreciate if any one can give me advice for enable this config on chromedriver. I have take a look at project https://github.com/GoogleChrome/lighthouse and i know we can using 'disabled-by-default-devtools.screenshot' for tracing screenshot in frame.
Thanks
Below is my sample code for this script:
import json
import time
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
performanceLogConfig = {
'traceCategories': 'toplevel,' +
'blink.console,' +
'blink.user_timing,' +
'benchmark,' +
'loading,' +
'latencyInfo,' +
'devtools.timeline,' +
'blink.image_decoding, ' +
'disabled-by-default-devtools.timeline,' +
'disabled-by-default-devtools.timeline.frame,' +
'disabled-by-default-devtools.timeline.stack,' +
'devtools.timeline.picture, ' +
'disabled-by-default-devtools.screenshot'
,
'enableNetwork': True,
'enablePage': True
}
options = webdriver.ChromeOptions()
options.add_experimental_option("perfLoggingPrefs", performanceLogConfig)
caps = DesiredCapabilities.CHROME
caps['loggingPrefs'] = {'performance': 'ALL', 'browser': 'ALL', 'driver': 'ALL'}
driver = webdriver.Chrome(
chrome_options=options,
desired_capabilities=caps,
service_args=[
"--enable-thread-composting ",
"--js-flags=--expose-gc ",
"--enable-gpu-benchmarking ",
"--disable-translate ",
"--disable-background-networking ",
"--safebrowsing-disable-auto-update ",
"--disable-sync --metrics-recording-only ",
"--disable-default-apps ",
"--no-first-run ",
"--flag-switches-begin ",
"--flag-switches-end ",
"--verbose ",
"--log-path=path"
]
)
driver.maximize_window()
driver.get("https://www.facebook.com/")
driver.find_element_by_id("email").send_keys("user")
driver.find_element_by_id("pass").send_keys("password")
driver.find_element_by_id("u_0_r").click()
time.sleep(10)
with open("log-performance.json", "wb") as f:
f.write("[")
for entries in driver.get_log('performance'):
for k, v in entries.iteritems():
f.write(str(json.dumps(entries)) + "\n,")
f.write("]")
driver.quit()
Same here, don't know why it doesn't work. I was able to get other perf logs except screenshots.
--
You received this message because you are subscribed to the Google Groups "ChromeDriver Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromedriver-users+unsub...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
The screenshot trace category is a little interesting.It relies on tracing being started from a given page, rather than at the browser level. (that way Chrome knows which tab to capture screenshots of)And Chromedriver attaches to tracing at the browser level, so that's why things fail.We've also encountered other peculiarities with the traces generated by Chromedriver. Lighthouse ended up with this approach to normalize those differences.
To unsubscribe from this group and stop receiving emails from it, send an email to chromedriver-users+unsubscribe@googlegroups.com.