0

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!

Andy T
  • 5
  • 2

2 Answers2

0

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

Kassab
  • 82
  • 1
  • 7
  • 1
    Thank you, this lead me to another stack overflow where I found pyautogui. That did the trick for me! – Andy T Jul 04 '22 at 13:58
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jul 04 '22 at 18:52
  • FYI for anyone else. >import pyautogui >pyautogui.press('f12') – Andy T Jul 04 '22 at 22:02
-1

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)
Ketan Pardeshi
  • 516
  • 1
  • 5
  • 8
  • Even though `send_keys` returns `None` method should still be executed in a moment of `search` definition – JaSON Jul 04 '22 at 10:11
  • I tried removing search, but it had the same result. The search function in there was from other testing. – Andy T Jul 04 '22 at 10:21