Posting the code snippet
for abc in self.driver.find_elements_by_xpath(
"//div[@class='ag-body-viewport']//div[starts-with(@class,'ag-row')]"):
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:
time.sleep(15)
self.actions.double_click(xyz)\
.send_keys(Keys.CONTROL + "a").send_keys(Keys.DELETE)\
.send_keys(1000).send_keys(Keys.ENTER).perform()
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