Monday 16 November 2020

Selenium Chrome Webdriver not working in headless mode with profile

So, this is the code I'm having troubles with:

def scrap():
        options = webdriver.ChromeOptions();
        options.add_argument('headless');
        options.add_argument('--profile-directory=Profile 1')
        options.add_argument("--user-data-dir=C:/Users/omarl/AppData/Local/Google/Chrome/User Data/")
        options.add_argument("--remote-debugging-port=45447")
    
        options.add_argument("--disable-gpu") 
        browser = webdriver.Chrome(executable_path=r"C:\Users\omarl\OneDrive\Escritorio\chromedriver.exe", options=options)
        
        scrapURL = "https://es.wallapop.com/search?distance=30000&keywords=leggins&latitude=41.38804&longitude=2.17001&filters_source=quick_filters"
        browser.get(scrapURL)
        #...

And the error:

WebDriverException: unknown error: unable to discover open pages

I don't have any instances of chrome when I execute the script, and when I'm using it without the headless option it works fine. Any idea why this is happening? Please, note that I'm using the --remote-debuggin-port provided in similar questions.

I'm using ChromeDriver 86.0.4240.22



from Selenium Chrome Webdriver not working in headless mode with profile

No comments:

Post a Comment