0
I wanted to know how to run a script by F12 ( Developer Tools ) by Selenium, I wanted him to open F12, then I would go to the Console and put the script there, I tried driver.execute_script('script'), but it only works if I have the F12 open in Google.
What I got so far is this
from selenium import webdriver
browser = webdriver.Chrome()
browser.get(URL_SITE)
browser.execute_script("var iframe = document.createElement('iframe');iframe.onload = function(){var ifrLocalStorage = iframe.contentWindow.localStorage; return ifrLocalStorage.getItem('token');};iframe.src = 'about:blank';document.body.appendChild(iframe);")
Hi Ped, the
execute_script
don’t need Devtools open, you’re probably making some mess.– Guilherme Nascimento
Did you already look at the actionschains? By them you press the F12 https://selenium-python.readthedocs.io/api.html
– BielSousa
I got @Bielsousa, I put in options to open with options.add_argument('auto-open-devtools-for-tabs'), thanks for the reply
– Ped