i am using selenium in python, as i am creating a BOT to automate some process. as for the bot it works good a captcha needs to be solved to go to the next process. but when the captcha is wrong i get the below error messageenter image description here
i tried the below code by getting the xpath of the ok button.
try:
wrongCaptchaOkButton = driver.find_element(By.XPATH,'//*[@id="btnOk"]')
wrongCaptchaOkButton.click()
wrongCaptchaHomeButton = driver.find_element(By.XPATH,'//*[@id="hmbtn"]/input')
wrongCaptchaHomeButton.click()
slotBooking(web,ApplicationNo,DOB)
except:
pass
the above codes doesnt click the ok button and it moves on to the rest of the code after the try and except function and gives error message.
if the error message is not present then the code runs smooth. i am new to python, is there any other way to select the ok button other than this. below is the element code for the okay button. enter image description here
but still it doesnt get the button and goes to next code and throws error
i tried getting the button using id
wrongCaptchaOkButton = web.find_element(By.ID,'btnOk')
also,i tried the following code.
WebDriverWait(driver, 10).until(EC.alert_is_present())
driver.switch_to.alert.accept()
wrongCaptchaHomeButton = driver.find_element(By.XPATH,'//*[@id="hmbtn"]/input')
wrongCaptchaHomeButton.click()
slotBooking(web,ApplicationNo,DOB)