导入from selenium.common.exceptions import NoSuchElementException,判断元素是否存在
def toast(self,tex):
try:
self.toast_loc = (By.XPATH,"//*[contains(@text,’"+tex+"’)]")
except NoSuchElementException:
logging.info(“xxxx”)
return None
else:
texts = self.driver.find_element(*self.toast_loc)
logging.info(“xxxxx”)
return texts.text