How to Bypass Human Verification 'Press and Hold' Using Selenium in Python?

I am trying to scrape some product reviews using Selenium and Python from this site but it connects another site and shows a popup at any point randomly, where I need to press and hold the button for human verification.

I am using chrome web driver and tried to solve it, to get the path using driver.find_element_by_xpath and many other ways. I also found that the 'Press and Hold' button is inside an iframe and so tried to switch to the iframe by driver.switch_to_frame('//iframe') or driver.switch_to_frame(0) but I failed. I can't find any iframe name or id to take any action.

Is there any way to bypass or take action (pressing and holding the button) whenever it occurs (as a site or popup) and also dismiss other popups during the process using selenium and python? any suggestions would be greatly appreciated!

7

2 Answers

Jacob's solution from this issue here solves this problem.

import time
from selenium import webdriver as wd
from selenium.webdriver.common.action_chains import ActionChains

driver = wd.Chrome('./web driver/chromedriver.exe')
target_url = '
driver.get(target_url)
driver.maximize_window()

element = driver.find_element_by_css_selector('#px-captcha')
action = ActionChains(driver)
action.click_and_hold(element)
action.perform()
time.sleep(10)
action.release(element)
action.perform()
time.sleep(0.2)
action.release(element)

Use Chromedriver Undetected.. Check out the git link for setup. Quite simple to integrate

import undetected_chromedriver as uc
driver = uc.Chrome()
driver.get(')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Sophia Al-Mansoor

Sophia Al-Mansoor

Global Business & E-Commerce Reporter

Sophia analyzes international trade, startup ecosystems, retail transformation, and supply chain logistics for modern digital publications.

Share this article
Twitter Facebook Pinterest