How to take screenshot for every 10 seconds in selenium that is from beginning of TC to end of TC.
Say my TC duration is 100 sec I need 10 screenshots in total.
How to take screenshot for every 10 seconds in selenium that is from beginning of TC to end of TC.
Say my TC duration is 100 sec I need 10 screenshots in total.
You would not be able to achieve this with Selenium as it is single threaded. Any request must wait for the previous request to finish.
If you had a single process, even if you check after every command whether 10 seconds had passed, it would never be exactly 10 seconds as it is likely that a command was being processed during the exact moment. You would end up with screenshots of unequal periods between.
Even if you had 2 processes running; 1 executing the test commands, the other performing screenshots at exactly 10 seconds, you would still run in to the same issue.
As Selenium is single threaded, it would not process the request for a screenshot until any concurrent command had finished executing. Again you would end up with unequal periods between screenshots.
If you desperately need screenshots every 10 seconds, then you could look at using "GridExtras" (https://github.com/groupon/Selenium-Grid-Extras). This exposes a HTTP endpoint to take screenshots outside of Selenium, and if you had a 2 processes, the 2nd process could call this endpoint every 10 seconds.
Do not be put off by the fact it is called "Grid Extras". I personally use it to capture video without using Selenium Grid and instead I have a standalone selenium server running along side an instance of Grid Extras.