class MyPageIndex(object):
    def __init__(self):
        self.dr = GetAppiumDriver().driver

    def MyIcon_Btn_by_Id(self):  # Failed
        try:
            MyIcon_Btn_by_Id = self.dr.find_element_by_id(
                "com.icoolme.android.weather:id/login_icon")
        except Exception as err:
            assert False, "我的页面未定位到账户登录,by_id"
        return MyIcon_Btn_by_Id

    #
    # def MyIcon_Btn_by_Name(self):
    #     MyIcon_Btn_by_Name = self.dr.find_element_by_class_name("android.widget.Button")
    #     return MyIcon_Btn_by_Name
    def MyPageBtn_Android_Uiautomator(self):
        try:
            MyPageBtn_Android_Uiautomator = self.dr.find_element_by_android_uiautomator(
                "new UiSelector().text(\"登录帐号\")")
        except Exception as err:
            assert False, "我的页面为定位到账户登录,by_Uiautomator"
        return MyPageBtn_Android_Uiautomator

    def MyLoginText_by_Id(self):
        try:
            MyLoginText_by_Id = self.dr.find_element_by_id(
                "com.icoolme.android.weather:id/login_text")
        except Exception as err:
            assert False, "我的页面为定位到账户登录,by_id"
        return MyLoginText_by_Id
class HomePageIndex(object):
    def __init__(self):
        self.conn = GetAppiumDriver().driver

    def HomeBtn_By_Id(self):
        try:
            HomeBtn_By_Id = self.conn.find_element_by_id(RES().HomeBtn_By_Id)

        except Exception as err:
            assert False,\
            "Can not locate myBtn,By_id"
        return HomeBtn_By_Id


    def HomeBtn_by_Class_Name(self):
        try:
            HomeBtn_by_Class_Name = self.conn.find_elements_by_class_name(RES().HomeBtn_by_Class_Name)[3] #fail,can't use
        except Exception as err:
            assert False,\
                "Can not locate myBtn,By_class_name"
            return HomeBtn_by_Class_Name

    def HomeBtn_Android_Uiautomator(self):
        try:
            HomeBtn_Android_Uiautomator = self.conn.find_element_by_android_uiautomator(RES().HomeBtn_Android_Uiautomator)
        except:
            assert False,\
                "Can not locate myBtn,By_Uiautomator"
        return HomeBtn_Android_Uiautomator
    def HomeBtn_xpath(self):
        try:
            HomeBtn_xpath = self.conn.find_elements_by_xpath(RES().HomeBtn_xpath)
        except Exception as err:
            assert False,"Can not locate myBtn,By_xpath"
        return HomeBtn_xpath
class LoginPageIndex(object):
    def __init__(self):
        self.conn = GetAppiumDriver().driver

    def LoginPage_Text_Usr_By_Id(self):
        try:
            LoginPage_Text_Usr_By_Id = self.conn.find_element_by_id(
                "com.icoolme.android.weather:dimen/text_md")
        except Exception as err:
            assert False,\
                "Can not locate the loginBtn,By ID"
        return LoginPage_Text_Usr_By_Id

    def LoginPage_Text_Pwd_By_Id(self):
        try:
            LoginPage_Text_Pwd_By_Id = self.conn.find_element_by_id(
                "com.icoolme.android.weather:dimen/weather_last_update_time_stamp_textsize"
            )
        except Exception as err:
            assert False, "Can not locate the loginBtn,By ID"
        return LoginPage_Text_Pwd_By_Id

    def LoginPage_Text_Usr_Uiautotor(self):
        try:
            LoginPage_Text_Usr_Uiautotor = self.conn.find_element_by_android_uiautomator(
                "new UiSelector().text(\"请输入手机号/邮箱\")")
        except Exception as err:
            assert False, "Can not locate the loginBtn,Uiautomator"
        return LoginPage_Text_Usr_Uiautotor

    def LoginPage_Btn_by_Id(self):
        try:
            LoginPage_Btn_by_Id = self.conn.find_element_by_id(
                "com.icoolme.android.weather:dimen/city_image_view_height_5x2")
        except Exception as err:
            assert False, "Can not locate the loginBtn,By ID"
        return LoginPage_Btn_by_Id
class AccountInfoPage(object):
    def __init__(self):
        self.dr = GetAppiumDriver().driver

    def LogoutBtn_Id(self):
        try:
            LogoutBtn_Id = self.dr.find_element_by_id(
                "com.icoolme.android.weather:id/uac_account_logout_btn")
        except Exception as err:
            assert False, "Can not locate the LogoutBtn,By_Id"
        return LogoutBtn_Id

    def LogoutBtn_uiautomator(self):
        try:
            LogoutBtn_uiautomator = self.dr.find_element_by_android_uiautomator(
                "new UiSelector().text(\"退出登录\")")
        except Exception as err:
            assert False, "Can not locate the LogoutBtn,By_Uiautomator"
        return LogoutBtn_uiautomator
class GetPageElementText(object):
    def __init__(self):
        self.conn = GetAppiumDriver().driver

    def get_id(self, rev):
        get_id = self.conn.find_element_by_id(rev)
        return get_id

    def get_class_name(self):
        pass

    def get_xpath(self):
        pass

    def get_ids(self):
        pass

    def get_class_names(self):
        pass

    def get_uiautomator(self):
        pass