Python Selenium在同一测试用例中多次使用ActionChains执行double_click()

时间:2018-06-06 13:47:22

标签: python-3.x selenium selenium-webdriver

当我在项目中创建测试套件时,我需要在同一页面(在相同的测试用例中)的不同Web元素上执行double_click()5次。在执行第一次double_click之后,对同一web元素(第一个)执行第二次double_click()。我在第一次执行double_click()之后尝试使用reset_actions(),但它也没有用。我使用selenium 3.8.1版本。这是我的示例代码:

def setUp(self):
    self.web = Webdriver()
    self.act = ActionChains(self.web)

def TestCase(self):
    self.web.switch_to.default_content()
    self.web.switch_to_frame('frame_ID')
    self.act.double_click(self.web.find_element_by_link_text("ID-1")).perform()
    ActionChains(self.web).reset_actions()

    # Check something and close opened pop-up

    self.act.double_click(self.web.find_element_by_link_text("ID-2")).perform()
    ActionChains(self.web).reset_actions()

    # Check something and close opened pop-up

    self.act.double_click(self.web.find_element_by_link_text("ID-3")).perform()
    ActionChains(self.web).reset_actions()

    # Check something and close opened pop-up

    self.act.double_click(self.web.find_element_by_link_text("ID-4")).perform()
    ActionChains(self.web).reset_actions()

    # Check something and close opened pop-up

    self.act.double_click(self.web.find_element_by_link_text("ID-5")).perform()
    ActionChains(self.web).reset_actions()

    # Check something and close opened pop-up

    def tearDown(self):
    self.web.quit()

有没有办法在同一个测试用例中多次使用ActionChains double_click()?

0 个答案:

没有答案