I am trying to get a selenium opened webpage to use function keys, however they don't seem to do anything. Current code is below:
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver import ActionChains
from selenium.webdriver.common.keys import Keys
import time
url = 'https://www.google.com/'
driver = webdriver.Chrome()
actionChains = ActionChains(driver)
driver.get(url)
time.sleep(5)
driver.find_element(By.XPATH, '/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input').send_keys(Keys.F12)
There isn't an error after running it. It's just that nothing happens. Am I perhaps missing something? I am very confused.
Any assistance would be appreciated. Thanks!
CodePudding user response:
I think this problem hasn't been solved yet. but there are some suggested solutions to go around this, Check this post: Pressing "F12" key directly through Selenium
CodePudding user response:
send_keys does not return anything hence you have to remove search.
driver.find_element(By.XPATH, '/html/body/div[1]/div[3]/form/div[1]/div[1]/div[1]/div/div[2]/input').send_keys(Keys.F12)