01、封装清除文框内容的函数:base_page.py
#清除文本框内内容
def clean_text(self, text):
# 光标移动到末尾
self.driver.keyevent(123)
for i in range(0,len(text)):
# 退格键
self.driver.keyevent(67)
02、定义获取可用余额元素数据:locator.py
# 获取可用余额元素
get_current_money_loc = (MobileBy.CLASS_NAME,'android.widget.EditText')
03、 定义清除内容函数:invist.py (此类继承BasePage)
def clean_inputbox_content(self):
#以下的前三个方法需要自行封装
self.wait_eleVisible(self.get_current_money_loc)#等待元素
self.click_element(self.get_current_money_loc)#元素激活
context = self.get_element_atrribute(self.get_current_money_loc,'name')#获取属性值
self.clean_text(context)#调用封装清除文本内容函数
04、测试用例调用:test_invist.py
InvistPage(invist_Env).clean_inputbox_content()
#InvistPage(invist_Env)相当于driver