Will my selenium script in execution stops if my computer goes on sleep mode/ hibernate mode in my absence? if yes then what is the desired way to get rid of this?
2 Answers
First, Sleep or Hibernate will disconnect your internet services.
Second, Hibernate also discontinues or stops many processes.
In Sleep mode, your display is turned off by default.
So Selenium Webdriver will not found any screen to run the script.
Solution :
(1) Remove/Increase display turn off time from settings (Never turn off).
(2) Increase Sleep or Hibernate time also.
(3) If you want to run script from the locked system,you can run it with above solutions.
Note : Never run Selenium scripts in Sleep or Hibernate mode. You can lock your System. It will not discontinue execution of your scripts.
Thanks.
While this is an older question I thought I would answer this question as it may help someone else out. I have found that a selenium script can continue to run even in sleep mode (at least on Linux/Ubuntu). If you put the browser in headless mode when setting up the driver, it will continue even in sleep mode.
Here is a blog post discussing headless mode.
And here is a snippet that can be used if using Python and Firefox on Linux (should work on other OSes as well):
from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.firefox.options import Options
options = Options()
options.add_argument("--headless")
browser = webdriver.Firefox(options=options)
browser.get("your_favorite_url_website_here")