Skip to content
Advertisement

Python Selenium’s send_keys function will not trigger a key after tabbing to the ReCaptcha v2 checkbox (to check the box)

from selenium.webdriver.common.keys import Keys

# ...
browser = webdriver.Chrome()

passwordBox = browser.find_element_by_css_selector('input[id="account_password"]')

passwordBox.send_keys(password)

passwordBox.send_keys(Keys.TAB + Keys.TAB + " ")

As I, among others, were having trouble simulating a click on the ReCaptcha v2 checkbox, one user found away to check it with Selenium’s Keys. That method is not working for me.

It traverses to the checkbox, but it just remains highlighted. It’s not a space that isn’t able to be sent at that point, but any key.

Advertisement

Answer

You cannot send anything to checkbox, you should click it . Try

passwordBox.send_keys(Keys.TAB + Keys.TAB + " ")
driver.switch_to_active_element().click()
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement