ticketing_layer.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:Tktr 作者: Intuity 项目源码 文件源码
def release_tickets(cls, type_name, quantity=100):
        # Login
        cls.admin_login()
        # Find the release link and click it
        cls.browser.get(cls.route_path("admin_tickets"))
        row = 1
        found = False
        while cls.is_element_present("//table/tbody/tr[%i]/td[1]" % row):
            name = cls.browser.find_element_by_xpath("//table/tbody/tr[%i]/td[1]" % row).text
            if type_name in name:
                cell = cls.browser.find_element_by_xpath("//table/tbody/tr[%i]/td[4]" % row)
                cell.find_element(By.CLASS_NAME, "release_tick_link").click()
                found = True
                break
            row += 1
        assert found, "Didn't find release link for ticket type!"
        # Now actually release some tickets
        cls.browser.find_element(By.ID, "number").send_keys(str(quantity))
        cls.browser.find_element(By.ID, "submit").click()
        # Deal with modal alert
        try:
            cls.browser.switch_to_alert().accept()
        except Exception:
            pass # Catch for PhantomJS
        # Logout
        cls.logout()
        # Return quantity
        return quantity
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号