问题
I am running my Selenium scrips in Windows machine, but during execution after some time the screen gets locked.
I have even set Never
for Power & Sleep
under Settings
. But still my laptop screen gets locked during execution.
I want to run all my scripts for hours together without getting my laptop screen locked or in sleep mode.
How can I achieve this?
回答1:
A simple vb script will help you resolve this. Create a .vbs file and paste the below code
set wsc = CreateObject("WScript.Shell")
Do
'one minute
WScript.Sleep(60*1000)
wsc.SendKeys("{NUMLOCK}")
Loop
The vbs script clicks Num Lock for every one minute and keeps the session active. Trigger that and the system will not get locked
Make sure that your Automation run will not get effected by pressing Num Lock
来源:https://stackoverflow.com/questions/52253368/to-keep-screen-active-without-locking-in-windows-while-running-selenium-script