Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
224 views
in Technique[技术] by (71.8m points)

javascript - Python selenium access sources tab in chrome dev tools

I am using selenium with python and want to access chrome dev tools.

I want to go into the sources tab and start coverage for the current page. After my selenium tests I want to download and save the coverage.json.

I have started by opening chrome with dev tools enabled, but I cant find a reliable way to continue.

options = webdriver.ChromeOptions()
options.add_argument("start-maximized")
options.add_argument("--auto-open-devtools-for-tabs")
browser = webdriver.Chrome(options=options)

I could mass send_keys until I am on the correct tab and count the tab keys from there until I am on the coverage tab and keep using this method, but it feels so hacky and unreliable. Isn't there a better way to do it? Atm. I have found nothing.

I can also execute JS in selenium with:

driver.execute("some js")

But I have also not found a way to do it with JS, is it even possible or do I search with the wrong keywords.

question from:https://stackoverflow.com/questions/66065794/python-selenium-access-sources-tab-in-chrome-dev-tools

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
Waitting for answers

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...