basepage 页,对元素定位与显示等待的封装
#元素定位与显示等待结合
def locator(self,loc):
ele = self.driver.find_element(loc)
try:
WebDriverWait(self.driver,timeout=10).until(EC.visibility_of_element_located(ele))
return ele
except Exception:
raise
#输入
def input(self,loc,txt):
self.locator(loc).send_keys(txt)
页面对象的元素定位,与操作方法
class Input(Page):
url = "https://www.baidu.com"
input_loc = (By.ID,'kw')
def send_keys(self,txt):
self.open(self.url)
self.input(self.input_loc,txt)