I'm trying to make a bot that logs inside my account. After inserting psw and username I make my bot clicking on "I'm not a robot" recaptcha checkbox.
After flagging the Recaptcha checkbox it could randomly appear a second Recaptcha, this time one with images. Fine, I could solve it by using the audio to text method. The issue is that this Recaptcha appears randomly.
I used an explicit wait but it gets bypassed and doesn't give me any errors.
Here's my code
#solve first recaptcha (I'm not a robot)
driver.switch_to_frame(element) #element = captcha frame already found
recaptcha = driver.find_element_by_xpath('//*[@id="recaptcha-anchor"]/div[1]')
driver.execute_script("arguments[0].click();",recaptcha)
_delay()
driver.switch_to_default_content()
#if an image captcha frame appears click on the audio button
try:
recaptcha_frame = WebDriverWait(driver, 10).until(
EC.presence_of_element_located((By.XPATH,
'/html/body/div/div/div[3]/div[2]/div[1]'))).find_element_by_tag_name('iframe') #locating the recaptcha image frame
driver.switch_to_frame(recaptcha_frame)
audio_button = driver.find_element_by_class_name('rc-button goog-inline-block rc-button-audio')
driver.execute_script("arguments[0].click();",audio_button)
except:
pass
If i would have used driver.quit() instead of pass it would have closed the session. My aim is to click on the audio_button. Any wonder on why this explicit wait doesn't work?