ultrafunkamsterdam / undetected-chromedriver

Custom Selenium Chromedriver | Zero-Config | Passes ALL bot mitigation systems (like Distil / Imperva/ Datadadome / CloudFlare IUAM)
https://github.com/UltrafunkAmsterdam/undetected-chromedriver
GNU General Public License v3.0
9.22k stars 1.1k forks source link

The easy example code in the README.md does not work anymore #1022

Open ArmandBENETEAU opened 1 year ago

ArmandBENETEAU commented 1 year ago

Hello, and first of all thanks for all the great work!

It seems that the following example code does not work anymore:

import undetected_chromedriver.v2 as uc
driver = uc.Chrome()
driver.get('https://nowsecure.nl')  # my own test test site with max anti-bot protection

Indeed the driver get stuck at the CloudFlare security challenge, waiting for the captcha I guess...

Thank you by advance for your answers!

ManiMozaffar commented 1 year ago

Hello, It works for me by adding some sleeps after driver.get.

Notice that in latest version, driver get closed automatically as gc is collected. so here's what actually happens --> website loads driver get closed so you never see the result that you were detected or not. Try adding some sleep, then you'll see once you're redirected to the blur page

import undetected_chromedriver as uc
import time
driver = uc.Chrome()
driver.get('https://nowsecure.nl')  # my own test test site with max anti-bot protection
time.sleep(20)
ArmandBENETEAU commented 1 year ago

Hello, thank you for your answer.

However, after further researches, I found out that was because the Cloudflare check was expecting me to click on a button to continue. So my problem disappears if I use this code instead.

import undetected_chromedriver as uc
import time

driver = uc.Chrome()
driver.get('https://nowsecure.nl')  # my own test test site with max anti-bot protection

# Wait a bit
time.sleep(20)

# Look for any input in the page
input_elements = browser.find_elements(By.TAG_NAME, "input")

# If there are some, click on the one allowing to "Verify you are human"       
if input_elements is not None:
            for element in input_elements:
                if "Verify you are human" in element.get_dom_attribute('value'):
                    print("Found button!, let's click on it")
                    element.click()
                    break

# Wait a bit until 'https://nowsecure.nl' is loaded
time.sleep(10)
thenik commented 1 year ago

Hi @ArmandBENETEAU

Does your code work for you now?

I want to use your sample on my case, but it does not work...

element.get_dom_attribute("value")

returns NonType ... and error - element not interactable..

Any ideas how is it possible to improve?

thenik commented 1 year ago

I tried to use this code ActionChains(self.driver).move_to_element(element).click(element).perform() from https://stackoverflow.com/questions/44119081/how-do-you-fix-the-element-not-interactable-exception but it does not work withthe same error...

ArmandBENETEAU commented 1 year ago

Hi @thenik,

Yeah the code I posted, with input_elements = browser.find_elements(By.TAG_NAME, "input") is working correctly for me.

In your case, if the call to element.get_dom_attribute('value') returns None it is maybe just that the element does not have any 'value' attribute. And therefore the function has nothing to return?