面对StaleElementReferenceException:消息:元素不再是有效的问题。请检查是否有出路

时间:2018-05-22 05:48:14

标签: python-2.7

  def ServerTimeWait(self):         driver = GenericFunctionLibrary.get_webdriver_instance()         尝试:             ElemStatus = WebDriverWait(driver,60).until(ec.presence_of_element_located(                 (By.XPATH,“// td / span [contains(text(),'server time:')] / following :: span [2]”)             ))             AppServerTime = driver.find_element_by_xpath(“// td / span [contains(text(),'server time:')] / following :: span [2]”)。text             如果AppServerTime.endswith('(UTC + 2)'):                UAppServerTime = AppServerTime [: - 8]             #print(“AppServerTime:”,AppServerTime)             formatAppServerTime = datetime.strptime(UAppServerTime,'%m /%d /%Y%H:%M')             print(“formatAppServerTime:”,formatAppServerTime)             fmt =“%m /%d /%Y%H:%M”             now_utc = datetime.now(时区('UTC'))             #print(“now_utc.strftime(fmt):”,now_utc.strftime(fmt))             now_paris = now_utc.astimezone(timezone('Europe / Paris'))             ##print“now_paris.strftime(fmt):”,now_paris.strftime(fmt)             #now_kolkata = now_paris.astimezone(timezone('Asia / Kolkata'))             ##print(“now_kolkata.strftime(fmt)”,now_kolkata.strftime(fmt))             finalSysDate = now_paris.strftime(fmt)             print(“finalSysDate”,finalSysDate)             如果formatAppServerTime == finalSysDate:                 print(“应用程序服务器时间与当前日期匹配”)             其他:                 print(“应用程序服务器时间与当前日期不匹配”)         除了例外e:             提高e  

0 个答案:

没有答案