Tests Fail in Headless mode

43 views
Skip to first unread message

Cory Musgrave

unread,
Apr 3, 2024, 11:49:31 AMApr 3
to ChromeDriver Users
I'm having trouble running selenium tests in headless mode.  Here are the options I'm using for ChromeDriver:
options.addArguments("--window-size=1920,1080");
options.addArguments("--no-sandbox");
options.addArguments("--headless");
options.addArguments("--allow-insecure-localhost");
options.addArguments("--ignore-certificate-errors");
options.setAcceptInsecureCerts(true);

this is the error message: 

org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"css selector","selector":"#username"}
  (Session info: chrome-headless-shell=123.0.6312.87)
For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
Build info: version: '4.17.0', revision: 'e52b1be057*'
System info: os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '14.2.1', java.version: '21.0.2'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [71b96c3533417ab6fb5bdeec6ba98a7f, findElement {value=username, using=id}]
Capabilities {acceptInsecureCerts: true, browserName: chrome-headless-shell, browserVersion: 123.0.6312.87, chrome: {chromedriverVersion: 123.0.6312.86 (9b72c47a0536..., userDataDir: /var/folders/5h/yfsjql21275...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:61184}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: mac, proxy: Proxy(), se:cdp: ws://localhost:61184/devtoo..., se:cdpVersion: 123.0.6312.87, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
Session ID: 71b96c3533417ab6fb5bdeec6ba98a7f

If I comment out the headless option the elements are found and the test works correctly.  Ideas?
Reply all
Reply to author
Forward
0 new messages