Search code examples
automated-testscypressweb-testing

Differences in behavior with headless and headed website testing


So we currently use TestComplete for our browser testing and want to switch to Cypress. One of my colleagues mentioned that headless testing isn't as reliable as when the clicks are simulated on a browser, like a real person would click (like in TestComplete). He said that since headless browsers only build up the DOM it could happen that if two buttons overlap the automated test could still be able to click on the overlapped button and the test would not fail and that this would not happen in TestComplete since it simulates a real user click.

Is that true because I don't think that this could actually happen?


Solution

  • Cypress click() command follow's Cypress' rules of actionability. One of these rules is for covering, which means that if a parent element is covering a child element, the element is not considered actionable. This would cover your specific concern, although you could override the actionability requirements by using cy.get('foo').click({ force: true }).

    Additionally, you can run Cypress in headed or headless mode. By default, executing Cypress with cypress run will execute Cypress in headless mode (this can be changed by passing in the headed flag: cypress run --headed), and will always run in headed mode when using cypress open. More information on that here.