0

I have a javascript which I want to put in console when page loaded but i am unable to open console using selenium in python I can access devtoos using this --auto-open-devtools-for-tabs but not able to open console.

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.action_chains import ActionChains
from selenium.common.exceptions import NoSuchElementException
import os
import time
from urllib.parse import quote_plus

driverPath = "chromedriver.exe"
dataPath = "whatsapp-assistant-bot-master/Data"

options = webdriver.ChromeOptions()
options.add_argument("--user-data-dir=" + dataPath)
options.add_argument("--auto-open-console-for-tabs=" + dataPath)
driver = webdriver.Chrome(options=options, executable_path=driverPath)

driver.get('http://google.com')
print('Please Scan the QR Code and press enter')

 driver.find_element_by_id("gsr").send_keys(Keys.F12)



input()
driver.quit()
Huzoor Bux
  • 1,026
  • 4
  • 20
  • 46

1 Answers1

2

Answered here, you don't have to open the console, you can run your js code through selenium

Running javascript in Selenium using Python

Marsilinou Zaky
  • 1,038
  • 7
  • 17