简体   繁体   中英

Automatically Run a Script in my Browser console after opening a link using Python

I want to run some JavaScript in my browser DevTools console. So far, I have opened up a specific website only through it. Can it be done in Python?

Right now, I am using the following code:

url = 'http://some-website.com/'

webbrowser.open(url)

What I want to do now is open up the DevTools console panel and then run a script through it automatically? Can it be done by using Python or some other tool along with Python?

I don't belive this can be done, as

ChromeDriver 2 and the DevTools windows both compete for the same automation channel, and ChromeDriver automatically closes the DevTools window in order for it to work.

See here for more: Chrome Developer Tools closes instantly when attempting to debug WebDriver E2E test

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM