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