标签:浏览器 通过 code not its des oca false elf
Helpdesk 的工作越来越难做了,做好服务还不够,受理工单还不能超时。 上面有要求,下面只能出对策了。还好实现起来简单。from selenium import webdriver
from selenium.webdriver.support.select import Select
import time
from selenium.webdriver.common.action_chains import ActionChains
Uname=‘XXXX‘
Pwd=‘XXXX‘
class Opera_ITSM():
def __init__(self,Uname=Uname,Pwd=Pwd):
self.Uname=Uname
self.Pwd=Pwd
url = ‘http://ITSM.XXX.COM/arsys/shared/login.jsp?/arsys/home‘
self.driver = webdriver.Chrome()
self.driver.get(url)
def ITSM_Login(self):
# time.sleep(5)
# 定位到攻略按钮
print(self.driver)
el_Uname=self.driver.find_element_by_xpath(‘//*[@id="username-id"]‘)
el_Pwd=self.driver.find_element_by_xpath(‘//*[@id="pwd-id"]‘)
el_submit=self.driver.find_element_by_xpath(‘//*[@id="login"]‘)
el_Uname.send_keys(self.Uname)
print(‘U‘)
time.sleep(1)
el_Pwd.send_keys(self.Pwd)
print("P")
# 点击操作,前提是定位到元素
time.sleep(1)
el_submit.click()
def Take_Ticket(self):
try:
time.sleep(5)
el_closeWindow=self.driver.find_element_by_xpath(‘//*[text()="已指派"]/..‘)
el_closeWindow.click()
check = self.driver.find_element_by_xpath(‘//*[@id="WIN_1_301428900"]/div[2]/div‘)
check.click()
time.sleep(2)
el_closeWindow=self.driver.find_element_by_xpath(‘//*[@id="WIN_2_301542000"]/a‘)
el_closeWindow.click()
time.sleep(2)
el_closeWindow=self.driver.find_element_by_xpath(‘//*[text()="受理事件"]‘)
el_closeWindow.click()
time.sleep(2)
el_closeWindow=self.driver.find_element_by_xpath(‘//*[@id="WIN_0_616122300"]‘)
el_closeWindow.click()
return(True)
except Exception as e:
print(e,‘刷新页面‘)
self.driver.refresh()
return(False)
if name == ‘main‘:
ITSM=Opera_ITSM()
ITSM.ITSM_Login()
while True:
print(time.asctime( time.localtime(time.time()) ))
if ITSM.driver:
res=ITSM.Take_Ticket()
if not res:
ITSM.Take_Ticket()
print(‘等待300秒‘)
time.sleep(300)
else:
print(‘等待20秒‘)
time.sleep(20)
标签:浏览器 通过 code not its des oca false elf
原文地址:https://blog.51cto.com/unicom/2458697