Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How i can enable 'disabled-by-default-devtools.screenshot'

863 views
Skip to first unread message

minhquan...@gmail.com

unread,
Jun 18, 2017, 1:19:01 AM6/18/17
to ChromeDriver Users
Hi all,

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()

ya...@google.com

unread,
Aug 30, 2017, 4:41:01 AM8/30/17
to ChromeDriver Users, minhquan...@gmail.com

Same here, don't know why it doesn't work. I was able to get other perf logs except screenshots.

Paul Irish

unread,
Aug 30, 2017, 7:35:50 PM8/30/17
to ya...@google.com, ChromeDriver Users, Quân Hoàng
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.


--
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.

Yao Zuo

unread,
Sep 1, 2017, 4:22:39 AM9/1/17
to Paul Irish, ChromeDriver Users, Quân Hoàng
Thanks Paul, I'm not familiar with lighthouse, do you managed to get screenshots from webdriver using this approach?

On Thu, Aug 31, 2017 at 7:35 AM, Paul Irish <paul...@google.com> wrote:
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.

Paul Irish

unread,
Sep 1, 2017, 4:00:11 PM9/1/17
to Yao Zuo, ChromeDriver Users, Quân Hoàng
No, Lighthouse connects to via the websocket endpoint of the DevTools protocol and starts tracing through that.

ChromeDriver has native bindings to Chrome and uses a browser-wide connection (when tracing is enabled). 


As far as I can tell it's not possible to get these screenshots from tracing through webdriver.
Reply all
Reply to author
Forward
0 new messages