def setUp(self, driver, request): driver.launch_app() yield allure.attach('Test completed screenshot', open(Util.saveExeScreenShot(Util(), driver, request.node.name), 'rb').read(), type=AttachmentType.PNG) driver.close_app()
def locateangularElement(self, loc, driver, request): try: element = WebDriverWait(self.driver, 10).until( EC.presence_of_element_located((By.XPATH, loc))) return element except: print("cannot find {0} element".format(loc)) logging.error("cannot find {0} element".format(loc)) allure.attach("cannot find {0} element".format(loc), open( Util.saveExeScreenShot(Util(), driver, request.node.name), 'rb').read(), type=AttachmentType.PNG) return None
def locateMutipleElements(self, loc, driver, request): # with pytest.raises(NoSuchElementException): try: # print(loc) elements = WebDriverWait(self.driver, 10).until( EC.presence_of_all_elements_located(loc)) # logging.info("Find elements of {0}".format(loc)) return elements except Exception as e: errList = traceback.format_exception(None, e, e.__traceback__) logging.error("Cannot find {0} element".format(loc)) allure.attach("Cannot find {0} element".format(loc), open( Util.saveExeScreenShot(Util(), driver, request.node.name), 'rb').read(), type=AttachmentType.PNG) assert 0, "Cannot find {0} element".format(loc)
def locateElement(self, loc, driver, request): try: # print(loc) element = WebDriverWait(self.driver, 10).until( EC.visibility_of_element_located(loc)) # logging.info("Find {0} element".format(loc)) return element except: # print("cannot find {0} element".format(loc)) logging.error("Cannot find {0} element".format(loc)) allure.attach("Cannot find {0} element".format(loc), open( Util.saveExeScreenShot(Util(), driver, request.node.name), 'rb').read(), type=AttachmentType.PNG) assert 0, "Cannot find {0} element".format(loc) return None