Open jesseimming opened 10 months ago
import undetected_chromedriver as uc import time
if name == 'main': options = uc.ChromeOptions() options.add_argument('--headless') driver = uc.Chrome(options=options, use_subprocess=True) driver.get('https://nowsecure.nl') time.sleep(5) driver.save_screenshot('nowsecure.png') # Wait for 5 seconds to ensure that the browser has fully loaded driver.quit()
You could try to open a new tab manually, and paste the url. You'll find it works. I have no idea why it works like this.😂
https://stackoverflow.com/questions/76582307/i-am-using-undetected-chromedriver
I'm a beginner in Python, but the page loads without any problems in Seleniumbase. I'm thinking of converting my projects to seleniumbase.
Curious. I read that on Hacker News several days ago and assumed it was NEWs.
The issue is with the window undetected chrome driver is focused on. Somehow cloudflare can detect that. The way arround is to load pages without focusing in them, you can do that this way:
driver.execute_script(f"window.open('{URL}', '_blank');")
time.sleep(3)
driver.switch_to.window(driver.window_handles[1])
Note that I am waiting for CloudFlare validation before switching to the window. This solves the issue for now
Actually the issue is not even focusing in the screen during Clouflare validation; If you ever focused on the screen the validation will fail even if you are not there while the validation is being done
driver.execute_script(f"window.open('_blank', 'Testing');")
driver.switch_to.window(driver.window_handles[1]
driver.switch_to.window(driver.window_handles[0]
driver.execute_script(f"window.open('{URL}', 'Testing');")
Even though I am not focusing on the testing window while the URL is loaded, it will be caught by cloudflare
The issue is with the window undetected chrome driver is focused on. Somehow cloudflare can detect that. The way arround is to load pages without focusing in them, you can do that this way:
driver.execute_script(f"window.open('{URL}', '_blank');") time.sleep(3) driver.switch_to.window(driver.window_handles[1])
Note that I am waiting for CloudFlare validation before switching to the window. This solves the issue for now
I was wondering how did the website detected if the window is being focused on or not? I've tried opening a new tab manually and executing switching to new window before opening the page, and the other time after opening the page. They all failed.
The issue is with the window undetected chrome driver is focused on. Somehow cloudflare can detect that. The way arround is to load pages without focusing in them, you can do that this way:
driver.execute_script(f"window.open('{URL}', '_blank');") time.sleep(3) driver.switch_to.window(driver.window_handles[1])
Note that I am waiting for CloudFlare validation before switching to the window. This solves the issue for now
It works for me. I cannot bypass detection even if manually enter the web url but this solution works.
Maybe I'm missing something here, I would assume:
driver.execute_script(f"window.open('{URL}', '_blank');")
Will open a new tab and focus it anyway?
I resorted to xvfb and it comes with the benefit of being able to record everything.
When opening, it still gives me the "checking if site is secure" problem. This is the code I used, did I do anything wrong?![nowsecure](https://github.com/ultrafunkamsterdam/undetected-chromedriver/assets/144343797/b41dfaa6-be31-4608-b3b5-a03469da37fa)