Python Selenium code is not able to double click on a webelement when multiple tests are run together

  • Posting the code snippet

    for abc in self.driver.find_elements_by_xpath(
                            flag = False
                            for xyz in abc.find_elements_by_tag_name("div"):
                                attr = xyz.get_attribute("colid")
                                if attr == "moduleName":
                                    module_name = cluster_module.text[:-3]
                                    # Check in the module given in input file is found on UI
                                    if module_name == input_module:
                                        logger.warning("Module {} found.....".format(input_module))
                                        flag = True
                                        logger.warning("Flag value {}".format(flag))
                                elif attr == "inventoryTarget":
                                    if flag:
                                                .send_keys(Keys.CONTROL + "a").send_keys(Keys.DELETE)\

    please note i have a suite with multiple test cases and each test case calls this function and it works for first testcase but fails after that for subsequent testcases

  • Seems like the flag is not being set to true on consecutive runs. You should check the module names in your if statement:

    if module_name == input_module

    I do not know what those 'modules' are, but it seems like this condition is not met.

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2