Search code examples
javaseleniumintellij-ideaautomated-testsheadless

Problem with Headless when running selenium test using java


I have a problem with running a test in headless mode. I wrote my test cases in two different (web shop and portal). Likewise, I am using Headless, my test works when headless is true in web-shop, but they don't work when headless is true in portal test cases.

org.openqa.selenium.ElementClickInterceptedException: element click intercepted: Element is not clickable at point (480, 483). Other element would receive the click: ... (Session info: headless chrome=91.0.4472.114) Build info: version: '4.0.0-beta-3', revision: '5d108f9a67' System info: host: 'moin-mkt-007.local', ip: 'fe80:0:0:0:1412:539b:3727:1402%en0', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.14.6', java.version: '14.0.2' Driver info: org.openqa.selenium.chrome.ChromeDriver Command: [d05ff1a9794fef32216ef34021b22337, clickElement {id=de6be461-9b49-4e10-8d99-c008af09b8ae}] Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 91.0.4472.114, chrome: {chromedriverVersion: 91.0.4472.101 (af52a90bf870..., userDataDir: /var/folders/p9/0lhk_6lj7x7...}, goog:chromeOptions: {debuggerAddress: localhost:9222}, javascriptEnabled: true, networkConnectionEnabled: false, pageLoadStrategy: normal, platform: MAC, platformName: MAC, proxy: Proxy(), se:cdp: ws://localhost:9222/devtool..., se:cdpVersion: 91.0.4472.114, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true} Element: [[ChromeDriver: chrome on MAC (d05ff1a9794fef32216ef34021b22337)] -> id: username] Session ID: d05ff1a9794fef32216ef34021b22337


Solution

  • You did not present your code here, but I guess you are missing maximizing screen in headless mode.
    So I think something like this should solve your problem:

    opts.addArguments("--headless", "--disable-gpu", "--window-size=1920,1200","--ignore-certificate-errors");