封装的隐示等待方法

#第一步:确定元素的定位表达式,这个是一个元组的格式,
invalid_msg_locator=("xpath", '//div[@class="layui-layer-content"]')#不输入密码错误的的提示信



#第二步:写一个方法封装隐示等待方法
# locator:tuple声明是一个元组
def wait_element_visible(self,locator:tuple):
#等待某个元素可见
wait = WebDriverWait(self.driver,timeout=20, poll_frequency=0.2)
e = wait.until(expected_conditions.visibility_of_element_located(locator))
return e


#第三步:调用隐示方法,让元素可见
def get_error_msg(self):
"""获取错误信息"""
e = self.wait_element_visible(self.error_msg_locator)传元素定位,不要加星号,这里不需要拆包
return e.text 千万不要加星号,会报错的




posted @ 2020-07-16 15:18  清扬惋惜  阅读(217)  评论(0编辑  收藏  举报