from lib.appController import driver_queue from lib.pyapp import Pyapp from lib.logger import logger class BasePage(object): def __init__(self, driver=None): try: self.driver = driver_queue.get() self.pyapp = Pyapp(self.driver) except Exception as e: logger.error('获取Driver出错:%s' % e) def reset_app(self): self.pyapp.reset() def quit(self): self.pyapp.quit() # class ThreadPage(BasePage): # def content_web_view(self): # self.pyapp.switch_web_view() # # def url(self): # self.pyapp.type('id=>url', 'http://ui.imdsx.cn/uitester/') # # def enter(self): # self.pyapp.key_code(66) # # def i1(self): # self.pyapp.type('css=>#i1', '1111111') class QQLogin(BasePage): def click_login(self): self.pyapp.click('id=>com.tencent.mobileqq:id/btn_login') def username(self): css = 'content=>请输入QQ号码或手机或邮箱' self.pyapp.type(css, 1061982257) def password(self): css = 'content=>密码 安全' self.pyapp.type(css, 'Yjbtest123') def login(self): css = 'android=>new UiSelector().text("登 录")' self.pyapp.click(css) # class Page(ThreadPage): class Page(QQLogin): pass