コード例 #1
0
 def setUp(self):
     self.driver = GetAppiumDriver().driver
     # time.sleep(20)
     time.sleep(20)
     for i in range(2):
         GetAppiumHelp().tap()
         time.sleep(2)
コード例 #2
0
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
コード例 #3
0
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
コード例 #4
0
 def __init__(self):
     #Global variable
     global x,y
     self.driver = GetAppiumDriver().driver
     #get the width of the Gphone's screen width
     x = self.driver.get_window_size()["width"]
     #get the height of the Gphone's screen height
     y = self.driver.get_window_size()["height"]
コード例 #5
0
    def setUpClass(cls):
        print("setUpClass")
        cls.driver = GetAppiumDriver().driver
        time.sleep(20)

        for i in range(2):
            GetAppiumHelp().tap()
            time.sleep(2)
コード例 #6
0
 def setUpClass(cls) -> None:  #只运行一次,最先运行
     # 类的实例化调属性
     cls.driver = GetAppiumDriver().driver
     time.sleep(7)
     # tipElement = cls.driver.find_element_by_id("com.jhss.youguu:id/rl_desktop_trade_new")
     # tipElement.find_element_by_xpath("//*[@class='android.widget.ImageView' and @index='0']").click()
     time.sleep(2)
     cls.driver.find_element_by_id(
         "com.jhss.youguu:id/login_by_simulate").click()
     time.sleep(2)
コード例 #7
0
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
コード例 #8
0
class LoginModel(unittest.TestCase):  #括号内为被继承的基类为unittest.TestCase
    #-------用例的构建和销毁-------
    #--用例执行初始化--
    def setUp(self):
        self.driver = GetAppiumDriver().driver
        # time.sleep(20)
        time.sleep(20)
        for i in range(2):
            GetAppiumHelp().tap()
            time.sleep(2)

    # 功能点测试用例方法的命名模式,方法以test开头,后跟实现用例的方法和命名
    def testLogin001(self):
        HomePageIndex().HomeBtn_Android_Uiautomator().click()
        time.sleep(2)
        MyPageIndex().MyLoginText_by_Id().click()
        time.sleep(2)
        LoginPageIndex().LoginPage_Text_Usr_Uiautotor().send_keys(
            "18983838625")
        #LoginPageIndex().LoginPage_Text_Usr_Uiautotor().send_keys(ReadXMLDriver().returnXMLfile("LoginData.xml","LoginData","Login001"))
        time.sleep(2)
        LoginPageIndex().LoginPage_Text_Pwd_By_Id().send_keys("12345678")
        time.sleep(2)
        LoginPageIndex().LoginPage_Btn_by_Id().click()
        time.sleep(2)

        expValue = "CC83483282"
        actValue = MyPageIndex().MyLoginText_by_Id().text
        msg = "登录测试失败"
        self.assertEqual(expValue, actValue,
                         msg)  #fail, if expValue != actValue,and print (msg)
        # self.assertEqual(expValue,actValue)

    #--用例执行完后善后操作(结束并清理)--
    def tearDown(self):
        self.driver.quit()  # end the server.session
        print("Login Test Ended")
コード例 #9
0
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
コード例 #10
0
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
コード例 #11
0
    def tearDownClass(cls) -> None:  #只运行一次,最后运行

        GetAppiumDriver().driver.quit()
コード例 #12
0
 def tearDownClass(cls):
     cls.driver = GetAppiumDriver().driver
     cls.driver.quit()
     print("tearDownClass")
コード例 #13
0
 def __init__(self):
     self.dr = GetAppiumDriver().driver
コード例 #14
0
class GetAppiumHelp(object):
    pass
    def __init__(self):
        #Global variable
        global x,y
        self.driver = GetAppiumDriver().driver
        #get the width of the Gphone's screen width
        x = self.driver.get_window_size()["width"]
        #get the height of the Gphone's screen height
        y = self.driver.get_window_size()["height"]

    def up_to_down(self):
        self.driver.swipe(x/2,y*0.2,x/2,y*0.9,500)

    def down_to_up(self):
        self.driver.swipe(x/2,y*0.9,x/2,y*0.2,500)

    def left_to_right(self):
        self.driver.swipe(x*0.2,y/2,x*0.9,y/2,500)

    def right_to_left(self):
        #self.driver.swipe(x*0.9,y*0.5,x*0.2,y*0.5,500)
        self.driver.swipe(x*0.9,y/2,x*0.2,y/2,500)

    def tap(self):
        self.driver.tap([(x/2,y/2)])