3

I am working with Selenium Webdriver using Python. I can navigate and do stuff normally when I run it through IDLE.

And also it works perfectly when I run it by task scheduler "Run with user logged on" but only manually if I make it run. If the system is locked, it stops near the SEND_KEYS function.

Attached the code:

from selenium import webdriver
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.action_chains import ActionChains
import time
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.select import Select
import os
import win32com.client as win32

driver=webdriver.Chrome()#chrome_options=options
driver.maximize_window()
window_before = driver.window_handles[0]
try:
        driver.get('https://itsm.windstream.com/')
        time.sleep(20)
        #WebDriverWait(driver,60)
        #pythoncom.CoInitialize()
        driver.switch_to_window(window_before)
        aw=True
        while aw:
            shell = win32.Dispatch("WScript.Shell")
            shell.Sendkeys('My_ID')
            shell.Sendkeys('{TAB}')
            shell.Sendkeys('My_password')
            shell.Sendkeys('{ENTER}')
            aw=False

except Exception as e:
        print (e)

It wont work directly, so I'm opening Chrome by local host and opening this file to run instead of batch file, which doesn't make any difference .

TylerH
  • 20,799
  • 66
  • 75
  • 101
Madan Raj
  • 279
  • 4
  • 15

1 Answers1

0

Try the schedule library for this; it worked for me:

import schedule

def start():
    print("{} Start the job".format(datetime.datetime.now()))

schedule.every().day.at("09:00").do(start)
TylerH
  • 20,799
  • 66
  • 75
  • 101
jasper
  • 123
  • 2
  • 10