4

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

0

2 Answers 2

3

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

Sign up to request clarification or add additional context in comments.

3 Comments

solver-button is now inside a closed shadow DOM. Last line of your code doesn't work anymore.
@abbr any ideas for closed shadow DOM?
@NamVu, I Submitted an issue to Buster github about closed shadow DOM. Author of buster replied Buster is not designed for automated testing script and deleted the issue ticket.
0

Now you need to do that in other way.

for frame in driver.find_elements(By.TAG_NAME, 'iframe'):
driver.switch_to.default_content()
driver.switch_to.frame(frame)

for shadowParent in driver.find_elements(By.CLASS_NAME, 'button-holder.help-button-holder'):
    try:
        actions.click(shadowParent).perform()
        
    except: continue

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.