Friday, April 15, 2022

[FIXED] How to bypass ReCaptcha with buster extension using Selenium and Python

Issue

Currently, I automate some processes using selenium and need to solve Google ReCaptcha. The technology used to solve the ReCaptcha is the browser, Plugin Buster. I enter the Google ReCaptcha using the following

driver.switch_to.frame(driver.find_elements_by_tag_name("iframe")[0])
check_box = WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.ID, "recaptcha-anchor")))
check_box.click()

Now I switch back to the default Frame using:

driver.switch_to.default_content()

So I need to click the Buster icon, but how to do that?

Icon to click:

Icon to click


Solution

The Buster icon is within another sibling <iframe>. So you have to:

  • Switch back to the default_content().

  • Induce WebDriverWait for the desired frame to be available and switch to it.

  • Induce WebDriverWait for the desired element to be clickable.

  • You can use the following Locator Strategies:

  • Code Block:

    from selenium import webdriver
    from selenium.webdriver.support.ui import WebDriverWait
    from selenium.webdriver.common.by import By
    from selenium.webdriver.support import expected_conditions as EC
    
    driver.switch_to.default_content()
    WebDriverWait(driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"//iframe[@title='recaptcha challenge']")))
    WebDriverWait(driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//button[@id='solver-button']"))).click()
    
  • Browser Snapshot:

recaptcha_iframe


Reference

You can find a couple of relevant discussions in:


Outro

Ways to deal with #document under iframe



Answered By - undetected Selenium
Answer Checked By - Clifford M. (PHPFixing Volunteer)

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.