from appium import webdriver
from appium.webdriver.common.mobileby import MobileBy
from bathroom_page.comon.base_page import BasePage
from bathroom_page.main import Main
class App(BasePage):
#启动欢迎页"同意"按钮
agree_loc = (MobileBy.ID, ‘com.qekj.merchant:id/tv_know’)
#"立即进入"按钮
open_loc = (MobileBy.ID, ‘com.qekj.merchant:id/btn_open’)
#agree_title = “同意”
update_alter = (MobileBy.ID, ‘com.qekj.merchant:id/ll_update’)
#app首页更新弹窗的取消按钮
update_cancel = (MobileBy.ID, ‘com.qekj.merchant:id/iv_cancel’)
shouyi_page = (MobileBy.ID, ‘com.qekj.merchant:id/rl_shouyi’)
#清空登录账号框按钮
clear_count_button = (MobileBy.ID, ‘com.qekj.merchant:id/iv_clear_account’)
#清空登录密码框按钮
clear_psw_button = (MobileBy.ID, ‘com.qekj.merchant:id/iv_clear_password’)
#登录页面账号输入框
account_input = (MobileBy.ID, ‘com.qekj.merchant:id/et_account’)
#登录页面密码输入框
password_input = (MobileBy.ID, ‘com.qekj.merchant:id/et_password’)
#登录页面"同意"按钮
agree_button = (MobileBy.ID, ‘com.qekj.merchant:id/iv_select’)
#登录页面"登录"按钮
login_button = (MobileBy.ID, ‘com.qekj.merchant:id/rl_login’)
#清空登录账号框按钮
clear_count = (MobileBy.ID, ‘com.qekj.merchant:id/iv_clear_account’)
#清空登录密码框按钮
clear_psw = (MobileBy.ID, ‘com.qekj.merchant:id/iv_clear_password’)
@property
def width(self):
'''获取屏幕宽度'''
return self._driver.get_window_size().get('width', 0)
@property
def height(self):
'''获取屏幕高度'''
return self._driver.get_window_size().get('height', 0)
def start(self):
if self._driver == None:
desired_caps = {}
desired_caps['platformName'] = 'android'
desired_caps['deviceName'] = 'emulator-5554'
desired_caps['appPackage'] = 'com.qekj.merchant'
desired_caps['appActivity'] = 'com.qekj.merchant.ui.activity.SplashActivity'
desired_caps['platformVersion'] = '6'
desired_caps['skipDeviceInitializatio'] = 'true'
desired_caps['uicodeKeyBoard'] = 'true'
desired_caps['resetKeyBoard'] = 'true'
desired_caps['noReset'] = 'true'
self._driver = webdriver.Remote("http://localhost:4723/wd/hub", desired_caps)
else:
self._driver.launch_app()
self._driver.implicitly_wait(10)
return self
def login_f(self):
#无论怎样,先点击登录账号输入框框右边"x"按钮空已填充账号
self._driver.find_element(str(self.clear_count)).click()
#无论怎样,先点击登录密码输入框右边"x"按钮清楚已填充账号
self._driver.find_element(str(self.clear_psw)).click()
#输入账号
self._driver.find_element(str(self.account_input)).send_keys("18814810220")
#输入密码
self._driver.find_element(str(self.password_input)).send_keys("123456")
try:
self._driver.find_element(str(self.agree_button)).click()
self._driver.find_element(str(self.login_button)).click()
except Exception as e:
self._driver.find_element(str(self.login_button)).click()
def stop(self):
pass
def restart(self):
pass
def main(self):
'''滑动引导页,进入登录页'''
try:
self._driver.find_element(str(self.agree_loc)).click()
except Exception as e:
lg = App()
lg.login_f()
try:
self._driver.find_element(str(self.update_cancel)).click()
except Exception as e:
pass
return Main(self._driver)