Created
December 8, 2017 18:36
-
-
Save miodeqqq/b416b42e1573e6d35f464375297a070c to your computer and use it in GitHub Desktop.
Clicks "I'm not robot" when captcha occurs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| from selenium import webdriver | |
| from selenium.webdriver import ActionChains | |
| from selenium.webdriver.common.by import By | |
| from selenium.webdriver.support import expected_conditions as ec | |
| from selenium.webdriver.support.ui import WebDriverWait | |
| driver = webdriver.Chrome() | |
| driver.get(url='https://www.google.com/recaptcha/api2/demo') | |
| # find iframe | |
| captcha_iframe = WebDriverWait(driver, 10).until( | |
| ec.presence_of_element_located( | |
| ( | |
| By.TAG_NAME, 'iframe' | |
| ) | |
| ) | |
| ) | |
| ActionChains(driver).move_to_element(captcha_iframe).click().perform() | |
| # click im not robot | |
| captcha_box = WebDriverWait(driver, 10).until( | |
| ec.presence_of_element_located( | |
| ( | |
| By.ID, 'g-recaptcha-response' | |
| ) | |
| ) | |
| ) | |
| driver.execute_script("arguments[0].click()", captcha_box) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment