Skip to content

[πŸ› Bug]: Fail to work on headless mode Β #14357

@Alperen-ylmaz

Description

@Alperen-ylmaz

What happened?

Hi I am trying to scrape links from websites however I got the error below. When run my script without headless mode it works but it doesnt work with headless mode.

[2024-08-08T10:53:33.515Z] Error processing request: Message:
[2024-08-08T10:53:33.530Z] Stacktrace:
[2024-08-08T10:53:33.530Z] 0 chromedriver 0x0000000100cd10b8 cxxbridge1$str$ptr + 1887276
[2024-08-08T10:53:33.530Z] 1 chromedriver 0x0000000100cc9794 cxxbridge1$str$ptr + 1856264
[2024-08-08T10:53:33.530Z] 2 chromedriver 0x00000001008d882c cxxbridge1$string$len + 88524
[2024-08-08T10:53:33.530Z] 3 chromedriver 0x000000010091c834 cxxbridge1$string$len + 367060
...
my driver setup below

def setup_driver():
options = Options()
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--window-size=1920x1080')
options.add_argument('--incognito')
options.add_argument('--headless') # Run in headless mode
options.add_argument('--disable-gpu')
driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=options)
return driver

Thanks in advance for your help! I really appreciate any advice you can give.

How can we reproduce the issue?

def setup_driver():
    options = Options()
    options.add_argument('--no-sandbox')
    options.add_argument('--disable-dev-shm-usage')
    options.add_argument('--window-size=1920x1080')
    options.add_argument('--incognito')
    options.add_argument('--headless')  # Run in headless mode
    options.add_argument('--disable-gpu')
    driver = webdriver.Chrome(service=Service(ChromeDriverManager().install()),options=options)    
    return driver

Relevant log output

[2024-08-08T10:53:33.515Z] Error processing request: Message:
[2024-08-08T10:53:33.530Z] Stacktrace:
[2024-08-08T10:53:33.530Z] 0   chromedriver                        0x0000000100cd10b8 cxxbridge1$str$ptr + 1887276
[2024-08-08T10:53:33.530Z] 1   chromedriver                        0x0000000100cc9794 cxxbridge1$str$ptr + 1856264
[2024-08-08T10:53:33.530Z] 2   chromedriver                        0x00000001008d882c cxxbridge1$string$len + 88524
[2024-08-08T10:53:33.530Z] 3   chromedriver                        0x000000010091c834 cxxbridge1$string$len + 367060

Operating System

Mac

Selenium version

python

What are the browser(s) and version(s) where you see this issue?

Chrome

What are the browser driver(s) and version(s) where you see this issue?

Chromedriver

Are you using Selenium Grid?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-needs-triagingA Selenium member will evaluate this soon!I-defectSomething is not working as intended

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions