0

I'm trying to use XPath to click a "click to verify" captcha button and it is not working. It returns the error message:

Message: no such element: Unable to locate element: {"method":"xpath","selector":"//*[@id="1e505deed3832c02c96ca5abe70df9ab"]/div"}

Here's my code:

click_to_verify = wd.find_element_by_xpath('//*[@id="1e505deed3832c02c96ca5abe70df9ab"]/div')
click_to_verify.click()

I'm not worried yet about the captcha that will appear when I click the button. I just want to be able to click the button. Any suggestions?

5
  • this can be because you are trying to click the box before it appears or you are using a wrong xpath, try waiting till the box appears or check the xpath Commented Jul 3, 2021 at 2:02
  • @EzyGrip I am not running all cells in the kernel, I am repeatedly editing and running the cell with the click code while on the page with the click to verify button. Nothing I'm trying is working. I've tried different xpaths and css selector. Commented Jul 3, 2021 at 3:02
  • can u pls provide the URL or the HTML details Commented Jul 3, 2021 at 4:51
  • from your post id looks dynamic one Commented Jul 3, 2021 at 4:51
  • there is something wrong with your x-path sometimes x-path's must be more specific or in other types of formats, please provide the target URL that we can give you a solution Commented Jul 3, 2021 at 4:58

2 Answers 2

0

I would probably say that the captcha you want to click is in iframe. It is very common design to put captcha in an iframe. If it's in iframe you would need to switch the focus of web driver like this :

wait = WebDriverWait(wd, 10)
wait.until(EC.frame_to_be_available_and_switch_to_it((By.XPATH, "iframe xpath")))
click_to_verify = wd.find_element_by_xpath('//*[@id="1e505deed3832c02c96ca5abe70df9ab"]/div')
click_to_verify.click()

and I would not recommend you to use 1e505deed3832c02c96ca5abe70df9ab in xpath, since it may change every time you execute your script .

Imports :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By
from selenium.webdriver.support import expected_conditions as EC
Sign up to request clarification or add additional context in comments.

Comments

0

So in the end I just decided to install pyautogui and use it to move the mouse to the specific part of the screen that needed to be clicked. Maybe not the most elegant solution but it worked for me in this situation.

import pyautogui

pyautogui.click(600, 525)

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.