Headless testing on Chrome browser fails few times for no reason

Hi there… I have seen that when I select headless testing on Chrome browser it fails few times for no reason. Where as normal execution with the Browser opened it works fine. Please provide solution

There are many things that could cause tests to fail in headless and pass in head mode. The most likely cause is timing. When the tests fail, what kind of error trace are you receiving? Please make sure that wherever there is alot of noise on a page upon surfacing that you have the appropriate waitFor… implemented for that page to be in a state where every element you need is ready for the action you want to perform. In headless things tend to run faster as the driver doesnt have to load a browser GUI meaning you can bypass all the time a real browser takes to load CSS, JavaScript and open and render HTML.