[BMC] ITSM自动接工单
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[BMC] ITSM自动接工单相关的知识,希望对你有一定的参考价值。
Helpdesk 的工作越来越难做了,做好服务还不够,受理工单还不能超时。 上面有要求,下面只能出对策了。还好实现起来简单。
练习通过id定位
导入webdrvier
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)
以上是关于[BMC] ITSM自动接工单的主要内容,如果未能解决你的问题,请参考以下文章
ManageEngine云ITSM系统助斯德雷特(Sterlite)年处理5万个工单