1

I wanted to automate a process but need to get through a reCaptcha and for that, I decided to use the extension called "Buster: Captcha Solver for Humans" link to the extension.

But the problem I encountered and have not found an answer to is, that I cannot click the actual buster button when the captcha is up.

This is the image of what the button looks like

To get to this point I would use the code -->

WebDriverWait(self.driver, 10).until(EC.frame_to_be_available_and_switch_to_it((By.CSS_SELECTOR,"iframe[name^='a-'][src^='https://www.google.com/recaptcha/api2/anchor?']")))
WebDriverWait(self.driver, 10).until(EC.element_to_be_clickable((By.XPATH, "//span[@id='recaptcha-anchor']"))).click()

But I seem to not be able to click the buster icon, the HTML code is as follows (sorry that it is picture format) enter image description here

The research I've done is that it is in #shadow-root (closed) and that is why I can't click or access it. Then I tried researching and from what I found, nothing worked.

(This topic has been asked but no answer gotten from it, do you, yes you! Want to be the first ever to answer this (at least from what I've seen)? Well what are you waiting for?)

My top questions are:

Maybe there is a better way (free) to bypass a reCaptcha and preferably also a hCaptcha? How can I click the element with selenium or any other python3 package?

martispyc
  • 77
  • 1
  • 3
  • 8

1 Answers1

1

Now let me tell you a few things

  • way1 is so basic but not dinamic;

you can do it with a python module; this module name is pyautogui

import pyautogui

pyautogui.click(x=X coordinate of the button you want to press, y=#Y coordinate of the button you want to press)

you can ask how can know cordinates of button, you can use pyautogui.position() and after find cordinates use them on above

NOTE: don't forget that when in the background you can't click your button(here is the why not dinamic)


  • way2 is may be hard :)

I don't think this(shadow-root) is the reason why you can't press the button. As for my guess;

as far as i know the button you are looking for is inside the iframe so you can't click until you get inside the iframe. Since I don't know the id of the button you are looking for and I don't have much time for now, let me show you how the audio button is pressed (the logic is probably the same as the button you are looking for) . All you have to do is to write the correct id.

class Captcha:
    def __init__(self):
        self.option = webdriver.ChromeOptions()
        self.option.add_argument('--disable-notifications')
        self.option.add_argument('--mute-audio')
        self.option.add_argument("user-agent=Mozilla/5.0 (iPhone; CPU iPhone OS 10_3 like Mac OS X) AppleWebKit/602.1.50 (KHTML, like Gecko) CriOS/56.0.2924.75 Mobile/14E5239e Safari/602.1")

        self.driver = webdriver.Chrome(options = self.option)

    def start_to_bypasscaptcha(self):
        self.driver.get(#URL of site)

        time.sleep(5)
        googleClass = self.driver.find_elements_by_class_name('g-recaptcha')[0]
        outeriframe = googleClass.find_element_by_tag_name('iframe')
        outeriframe.click()

        allIframesLen = self.driver.find_elements_by_tag_name('iframe')
        audioBtnFound = None
        audioBtnIndex = -1

        for index in range(len(allIframesLen)):
            self.driver.switch_to.default_content()
            iframe = self.driver.find_elements_by_tag_name('iframe')[index]
            self.driver.switch_to.frame(iframe)
            try:
                print(self.driver.find_element_by_id("audio-instructions").text)
                time.sleep(1)
                audioBtn = self.driver.find_element_by_id('recaptcha-audio-button') or self.driver.find_element_by_id('recaptcha-anchor')
                audioBtn.click()
                audioBtnFound = True
                audioBtnIndex = index
                break
            except Exception as error:
                pass

        time.sleep(3)
        if audioBtnFound:
            #do what do you want
        else:
            print('Button not found.')

If you apply this code to the button you want properly and it doesn't work, you are right, shadow-root may be the cause of this problem.


description of my code;

  • open chrome using selenium
  • go to the URL
  • wait a few second after that find captcha
  • Find all iframes inside captcha frame
  • every time go inside the found iframes and try to click the button
  • when you find the clickable button end the loop and assign a variable which iframe the button belongs to

Very serius note; I would like to point out that the second way was not written for the purpose of giving an answer, the main purpose is to show the logic.

just a stranger
  • 310
  • 1
  • 4
  • 13
  • Hello, I am very grateful for the answer. I did some research and you are right, it was because of the iframe, but the shadow-root was a problem, I decided to just click the div. Do you have any tips to make it so reCaptcha doesn't flag me as a bot and say the "your computer or network may be sending automated queries"? Like mouse moving or a special user agent I can use or even better some option? – martispyc Jul 11 '21 at 12:37
  • @martispyc, maybe this [Q/A](https://stackoverflow.com/questions/55501524/how-does-recaptcha-3-know-im-using-selenium-chromedriver?noredirect=1&lq=1) can help you – just a stranger Jul 20 '21 at 05:35