from selenium import webdriver
from time import sleep
from selenium.webdriver.common.action_chains import ActionChains
# 加上参数,禁止 chromedriver 日志写屏
options = webdriver.ChromeOptions()
options.add_experimental_option(
'excludeSwitches', ['enable-logging'])
driver = webdriver.Chrome(
r'C:\Program Files\Google\Chrome\chromedriver.exe',
options=options # 指定 options 参数
)
# driver = webdriver.Chrome(r'C:\Program Files\Google\Chrome\chromedriver.exe')
driver.get('https://booking-new.clounix.com/login')
# 输入登录名和密码,并点击登录
element = driver.find_element_by_xpath("/html/body/div/div/div/form/div[1]//input")
element.send_keys('yanghui2')
element = driver.find_element_by_xpath("/html/body/div/div/div/form/div[2]//input")
element.send_keys('123456')
element = driver.find_element_by_xpath("/html/body/div/div/div/form/div[3]//button").click()
# hold test
# hold free DUT
# elements = driver.find_elements_by_css_selector("#app .mid .left .el-table--fit .el-table__body .el-table__row .el-button")
sleep(1)
trlist = driver.find_elements_by_css_selector("#app .mid .left .el-table--fit .el-table__body .el-table__row .el-button")
print(len(trlist))
for row in trlist:
row.click()
_item = driver.find_element_by_css_selector("#app > div > div.mid > div.left > div.el-overlay > div > div > div.el-dialog__body > div.el-select > div > div > span > span > i")
ActionChains(driver).move_to_element(_item).click(element).perform()
_hold = driver.find_element_by_xpath('//div[starts-with(@id,"el-popper")]/div[1]/div/div[1]/ul/li[1]')
ActionChains(driver).move_to_element(_hold).click(element).perform()
_confirm = driver.find_element_by_xpath('//*[@id="app"]/div/div[2]/div[1]/div[3]/div/div/div[2]/button')
ActionChains(driver).move_to_element(_confirm).click(element).perform()
# sleep(6)
# hold occupied DUT
for row in trlist:
row.click()
_item = driver.find_element_by_css_selector("#app > div.mid > div.left > div.el-overlay > div > div > div.el-dialog__body > div.el-select > div > div > span > span > i > svg > path")
ActionChains(driver).move_to_element(_item).click(element).perform()
_hold = driver.find_element_by_xpath('//div[starts-with(@id,"el-popper")]/div[1]/div/div[1]/ul/li[1]')
ActionChains(driver).move_to_element(_hold).click(element).perform()
_confirm = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[3]/div/div/div[2]/button/span')
ActionChains(driver).move_to_element(_confirm).click(element).perform()
# sleep(6)
# hold DUT always but not using
_longDUT = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[2]/div[3]/table/tbody/tr[8]/td[5]/div/div/button').click()
_item = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[3]/div/div/div[2]/div[1]/div/div/span/span/i')
ActionChains(driver).move_to_element(_item).click(element).perform()
_4hour = driver.find_element_by_xpath('//div[starts-with(@id,"el-popper")]/div[1]/div/div[1]/ul/li[8]')
ActionChains(driver).move_to_element(_4hour).click(element).perform()
_confirm = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[3]/div/div/div[2]/button/span')
ActionChains(driver).move_to_element(_confirm).click(element).perform()
# trigger booking
driver2 = webdriver.Chrome(r'C:\Program Files\Google\Chrome\chromedriver.exe')
driver2.get('https://booking-new.clounix.com/login')
element = driver2.find_element_by_xpath("/html/body/div/div/div/form/div[1]//input")
element.send_keys('yanghui')
element = driver2.find_element_by_xpath("/html/body/div/div/div/form/div[2]//input")
element.send_keys('123456')
element = driver2.find_element_by_xpath("/html/body/div/div/div/form/div[3]//button").click()
_longDUT = driver2.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[2]/div[3]/table/tbody/tr[8]/td[5]/div/div/button').click()
_item = driver2.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[3]/div/div/div[2]/div[1]/div/div/span/span/i')
ActionChains(driver2).move_to_element(_item).click(element).perform()
_4hour = driver2.find_element_by_xpath('//div[starts-with(@id,"el-popper")]/div[1]/div/div[1]/ul/li[8]')
ActionChains(driver2).move_to_element(_4hour).click(element).perform()
_confirm = driver2.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[3]/div/div/div[2]/button/span')
ActionChains(driver2).move_to_element(_confirm).click(element).perform()
# release booking DUT
row = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[2]/div[3]/table/tbody/tr/td[5]/div/div/button[2]')
row.click()
_release = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[2]/div[3]/table/tbody/tr/td[5]/div/div/button[2]')
ActionChains(driver).move_to_element(_release).click(element).perform()
_ok = driver.find_element_by_xpath("/html/body/div/div/div[3]/button").click()
# release all occupied DUT
res_trlist = driver.find_elements_by_xpath('//*[@id="app"]/div[2]/div[1]/div[2]/div[3]/table/tbody/tr')
print(len(res_trlist))
for row in res_trlist:
row = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[2]/div[3]/table/tbody/tr/td[5]/div/div/button[2]')
row.click()
_release = driver.find_element_by_xpath('//*[@id="app"]/div[2]/div[1]/div[2]/div[3]/table/tbody/tr/td[5]/div/div/button[2]')
ActionChains(driver).move_to_element(_release).click(element).perform()
_ok = driver.find_element_by_xpath("/html/body/div/div/div[3]/button").click()
sleep(9)