Undetectedchromedriver not open

159 Views Asked by At

Why it isnt working

from selenium import webdriver
import undetected_chromedriver as uc

if __name__ =='__main__':
    options = uc.ChromeOptions()
    options.add_argument("--headless")
    driver = uc.Chrome(options=options)
    driver.get('https://nowsecure.nl')
    driver.save_screenshot('nowsecure.png')

The code executes and the screenshot is taken and saved but de webpage window doesn't open, even taking out the screenshot code line the webpage doesn't open so i can use it.

3

There are 3 best solutions below

1
On

Comment this line:

# options.add_argument("--headless")   
0
On

I solved the problem adding setting headless by another way and the closing using timesleep

import undetected_chromedriver as uc
import time


options = uc.ChromeOptions()
options.headless = False
driver = uc.Chrome(options=options)
driver.get("https://nowsecure.nl")
time.sleep(100)
0
On

I think there is a problem with running headless using undetected chromedriver. You can take a look at this SO.

from seleniumbase import Driver # pip install seleniumbase
import time

driver = Driver(uc=True)
driver.get('https://nowsecure.nl')
time.sleep(6)
driver.quit()