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 .