def choose_ticket(self):
if self.status == 2: #登录成功入口
print("="*30)
print("###开始进行日期及票价选择###")
while self.driver.title.find(确认订单) == -1: # 如果跳转到了订单结算界面就算这步成功了,否则继续执行此步
try:
buybutton = self.driver.find_element_by_class_name(buybtn).text
if buybutton == "提交缺货登记":
# 改变现有状态
self.status=2
self.driver.get(target_url)
print(###抢票未开始,刷新等待开始###)
continue
elif buybutton == "立即预定":
self.driver.find_element_by_class_name(buybtn).click()
# 改变现有状态
self.status = 3
elif buybutton == "立即购买":
self.driver.find_element_by_class_name(buybtn).click()
# 改变现有状态
self.status = 4
# 选座购买暂时无法完成自动化
elif buybutton == "选座购买":
self.driver.find_element_by_class_name(buybtn).click()
self.status = 5
except:
print(###未跳转到订单结算界面###)
title = self.driver.title
if title == 选座购买:
# 实现选座位购买的逻辑
self.choice_seats()
elif title == 确认订单:
while True:
# 如果标题为确认订单
print(waiting ......)
if self.isElementExist(//*[@id="container"]/div/div[9]/button):
self.check_order()
break
暂时没有评论,来抢沙发吧~