My selenium script is not working on headless mode but working fine without headless. Error msg (NoSuchElementException)?why?
Increase time.sleep 2 to 10 but still not working
My selenium script is not working on headless mode but working fine without headless. Error msg (NoSuchElementException)?why?
Increase time.sleep 2 to 10 but still not working
Some of the applications do not work properly in the headless mode due to the application firewall. In that case, you need to debug what is showing inside headless.
Take a snapshot using selenium and see what is showing before the element not found exception
If you found your application is blocked to load in headless then follow the steps
To bypass the firewall you can use following argument in your python script. I used it in my java so i mention it in java. You can convert to your desire language
options.addArguments("--headless");
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
options.setExperimentalOption("useAutomationExtension", false);
options.addArguments("user-agent=Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.125 Safari/537.36");