9

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?

0

2 Answers 2

17

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.

1
  • Right answer. I am also using same approach.
    – Sagar007
    Commented May 28, 2015 at 10:01
6

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")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.