Пример #1
0
class Base(object):
    def __init__(self):
        self.driver = AppiumSetup().driver

    def find_element(self, item, loc, wait):
        try:
            if item == 'id':
                element = WebDriverWait(
                    self.driver,
                    wait).until(lambda driver: driver.find_element_by_id(loc))
            elif item == 'xpath':
                element = WebDriverWait(self.driver, wait).until(
                    lambda driver: driver.find_element_by_xpath(loc))
            elif item == 'accessibility':
                element = WebDriverWait(
                    self.driver,
                    wait).until(lambda driver: driver.
                                find_element_by_accessibility_id(loc))
        except AssertionError:
            AppiumSetup().add_img()
            LogFile().error(u"%s 页面中未能找到 %s 元素" % (self, loc))

        return element

    def find_elements(self, item, loc, wait):

        try:
            if item == 'id':
                elements = WebDriverWait(
                    self.driver,
                    wait).until(lambda driver: driver.find_elements_by_id(loc))
            elif item == 'xpath':
                elements = WebDriverWait(self.driver, wait).until(
                    lambda driver: driver.find_elements_by_xpath(loc))
            elif item == 'accessibility':
                elements = WebDriverWait(
                    self.driver,
                    wait).until(lambda driver: driver.
                                find_elements_by_accessibility_id(loc))
        except AssertionError:
            AppiumSetup().add_img()
            LogFile().error(u"%s 页面中未能找到 %s 元素" % (self, loc))

        return elements

    def send_keys(self, item, loc, value, clear_first=True, click_first=True):
        try:
            if click_first:
                self.find_element(item, loc, wait=10).click()
            if clear_first:
                self.find_element(item, loc, wait=10).clear()
            self.find_element(item, loc, wait=10).send_keys(value)
        except AttributeError:
            LogFile().error(u"%s 页面中未能找到 %s 元素" % (self, loc))

            # 重新封装按钮点击方法

    def click_button(self, item, loc, find_first=True):
        try:
            if find_first:
                self.find_element(item, loc, wait=10)
            self.find_element(item, loc, wait=10).click()
        except AttributeError:
            LogFile().error("%s 页面未能找到 %s 按钮" % (self, loc))

    def swipe(self, st, sy, ex, ey):
        """
        滑动
        分别为:起始点x,y。结束点x,y。与滑动速度。滑动默认800
        """
        return self.driver.swipe(st, sy, ex, ey, duration=300)

    def get_window_size(self):
        """
        获取屏幕分辨率
        {u'width': 1080, u'height': 1920}
        :return: 1080,1920
        """

        screen_size = self.driver.get_window_size()
        width = screen_size['width']
        height = screen_size['height']
        return width, height

    def swipe_ratio(self, st, sy, ex, ey):
        """
        :param st: 起始点宽
        :param sy: 起始点高
        :param ex: 结束点宽
        :param ey: 结束点高
        :return: 滑动动作
        """
        width, height = self.get_window_size()
        return self.swipe(str(st * width), str(sy * height), str(ex * width),
                          str(ey * height))

    def swipe_left(self, get_num):
        """
        左滑屏幕
        """
        num = 0
        while num < get_num:

            self.swipe_ratio(0.8, 0.5, 0.2, 0.5)
            time.sleep(1)
            num += 1

    def swipe_right(self, get_num):
        """
        右滑屏幕
        """
        num = 0
        while num < get_num:
            self.swipe_ratio(0.2, 0.5, 0.8, 0.5)
            time.sleep(1)
            num += 1

    def swipe_up(self, get_num):
        """
        上滑屏幕
        """
        num = 0
        while num < get_num:
            self.swipe_ratio(0.5, 0.8, 0.5, 0.2)
            time.sleep(1)
            num += 1

    def swipe_down(self, get_num):
        """
        下滑屏幕
        """
        num = 0
        while num < get_num:
            self.swipe_ratio(0.5, 0.2, 0.5, 0.8)
            time.sleep(1)
            num += 1

    def swipe_all(self, t):
        """
        选择如何滑动屏幕
        """
        if t == 'swipe_left':
            self.swipe_left()
        elif t == 'swipe_right':
            self.swipe_right()
        elif t == 'swipe_up':
            self.swipe_up()
        elif t == 'swipe_down':
            self.swipe_down()

    def save_screenshot(self, file_path):
        """
        :param file_path:
        :return: 获取android设备截图
        """

        return self.driver.save_screenshot(file_path)

    def start_activity(self, package, activity):
        """
        启动activity
        package:包名
        activity:.activity
        """
        return self.driver.start_activity(package, activity)

    def open_notifications(self):
        """
        打开系统通知栏
        """
        return self.driver.open_notifications()

    def is_app_installed(self, package):
        """
        检查是否安装
        package:包名
        """
        return self.driver.is_app_installed(package)

    def install_app(self, path):
        """
        安装应用
        path:安装路径
        """
        return self.driver.install_app(path)

    def remove_app(self, package):
        """
        删除应用
        package:包名
        """
        return self.driver.remove_app(package)

    def shake(self, ):
        """
        摇晃设备
        """
        return self.driver.shake()

    def close_app(self, ):
        """
        关闭当前应用
        """
        return self.driver.close_app()

    def reset_app(self, ):
        """
        重置当前应用
        """
        return self.driver.reset()

    def current_activity(self, ):
        """
        当前应用的activity
        """
        return self.driver.current_activity

    def send_key_event(self, arg):
        """
        操作实体按键
 
        """
        event_list = {
            'entity_home': 3,
            'entity_back': 4,
            'entity_menu': 82,
            'entity_volume_up': 24,
            'entity_volume_down': 25,
            "entity_enter": 66
        }
        if arg in event_list:
            self.driver.keyevent(int(event_list[arg]))

    def toggle_location_services(self):
        """
        开关定位服务

        """
        return self.driver.toggle_location_services()

    def clean_app(self, package_name):

        device_name = Base.get_devices_list(self)
        for i in range(len(device_name)):
            command = 'adb -s %s shell pm clear %s' % (device_name[i],
                                                       package_name)
            print(command)
            subprocess.getstatusoutput(command)

    def start_app(self, ):
        device_name = Base.get_devices_list(self)
        for i in range(len(device_name)):
            command = 'adb -s %s shell am start -W -n com.haolan.infomation/.activity.SplashActivity' % device_name[
                i]
            print(command)
            subprocess.getstatusoutput(command)

    def get_devices_list(self, ):
        command = 'adb devices'

        out = subprocess.getstatusoutput(command)
        ss = out[1].split('\n')
        ss_list = []

        for i in range(len(ss)):
            if ss[i].__contains__('device'):
                ss_list.append(ss[i])

        devices_list = []
        dd = ss_list[1:len(ss_list)]
        for j in range(len(dd)):
            devices_list.append(str(dd[j]).replace('\tdevice', ''))

        return devices_list

    def get_version(self, device_name):

        command = 'adb -s %s shell getprop ro.build.version.release' % device_name

        out = subprocess.getstatusoutput(command)

        version_name = list(out)[1]

        return version_name

    def find_toast(self):

        try:
            if self.find_element('xpath', '//*[@class="android.widget.Toast"]',
                                 10):
                toast_txt = self.driver.find_element_by_xpath(
                    '//*[@class="android.widget.Toast"]').text
                print(toast_txt)
            else:
                print('未找到 toast弹框')

        except AssertionError:
            AppiumSetup().add_img()
            LogFile().error('功能模块异常')

        return toast_txt

    def isElement(self, identifyBy, c):
        '''
        Determine whether elements exist
        Usage:
        isElement(By.XPATH,"//a")
        '''
        time.sleep(1)
        flag = None
        try:
            if identifyBy == "resource-id":
                # self.driver.implicitly_wait(60)
                self.driver.find_element_by_id(c)
            elif identifyBy == "xpath":
                # self.driver.implicitly_wait(60)
                self.driver.find_element_by_xpath(c)
            elif identifyBy == "class":
                self.driver.find_element_by_class_name(c)
            elif identifyBy == "link text":
                self.driver.find_element_by_link_text(c)
            elif identifyBy == "partial link text":
                self.driver.find_element_by_partial_link_text(c)
            elif identifyBy == "name":
                self.driver.find_element_by_name(c)
            elif identifyBy == "tag name":
                self.driver.find_element_by_tag_name(c)
            elif identifyBy == "css selector":
                self.driver.find_element_by_css_selector(c)
            flag = True
        except NoSuchElementException as e:
            flag = False
        finally:
            return flag

    def logout(self):
        " 退出登录"
        self.swipe_up(1)
        sleep(2)
        self.click_button(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_setting"]')
        self.click_button(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_setting_logout"]')

    def totopic(self):
        "到主题页"
        d = self.find_element('xpath', '//*[@text="热门"]', 10)
        # 点击主题
        self.click_button('xpath', '//*[@text="主题"]')

    def get_img(self):
        self.imgs = []
        self.imgs.append(self.driver.get_screenshot_as_base64())

    def take_screenShot(self, name="takeShot"):
        '''
        method explain:获取当前屏幕的截图
        parameter explain:【name】 截图的名称
        Usage:
            device.take_screenShot(u"个人主页")   #实际截图保存的结果为:2018-01-13_17_10_58_个人主页.png
        '''
        day = time.strftime("%Y-%m-%d", time.localtime(time.time()))
        fq = "..\\screenShots\\" + day
        # fq =os.getcwd()[:-4] +'screenShots\\'+day    根据获取的路径,然后截取路径保存到自己想存放的目录下
        tm = time.strftime("%Y-%m-%d_%H_%M_%S", time.localtime(time.time()))
        type = '.png'
        filename = ""
        if os.path.exists(fq):
            filename = fq + "\\" + tm + "_" + name + type
        else:
            os.makedirs(fq)
            filename = fq + "\\" + tm + "_" + name + type
        # c = os.getcwd()
        # r"\\".join(c.split("\\"))     #此2行注销实现的功能为将路径中的\替换为\\
        self.driver.get_screenshot_as_file(filename)
Пример #2
0
class MineTest(unittest.TestCase):
    "我的功能"

    def setUp(self):
        AppiumSetup().setUpClass(get_version='7.1.1', device_name='cea8dc6c')
        self.driver = AppiumSetup().driver
        self.b = BasePage.Base()
        self.h = FunctionHelper.Function()

    def test_a_mine_data(self):
        "未登录用户页面数据呈现"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        '点击我的'
        self.b.click_button('xpath', '//*[@text="我的"]')
        '校验我的页面内容呈现'
        d = self.b.find_element('xpath', '//*[@text="未登录"]', 5)
        self.assertTrue(d)
        # 消息通知
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_message"]',
            5)
        self.assertTrue(d)
        # 本地主题
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_local_theme"]', 5)
        self.assertTrue(d)
        # 我的收藏
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_collection"]', 5)
        self.assertTrue(d)
        # 制作主题
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_diy_theme"]', 5)
        self.assertTrue(d)
        # 意见反馈
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_feedback"]',
            5)
        self.assertTrue(d)
        # 版本升级
        d = self.b.find_element('xpath', '//*[@text="版本升级"]', 5)
        self.assertTrue(d)
        # 设置
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_setting"]',
            5)
        self.assertTrue(d)
        self.b.close_app()

    def test_b_mine_data(self):
        "本地主题内容"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        '点击我的'
        self.b.click_button('xpath', '//*[@text="我的"]')
        '校验我的页面内容呈现'
        d = self.b.find_element('xpath', '//*[@text="未登录"]', 5)
        self.assertTrue(d)
        self.b.click_button('xpath', '//*[@text="本地主题"]')
        #     校验本地主题页信息
        d = self.b.find_element('xpath', '//*[@text="视频"]', 5)
        self.assertTrue(d)
        d = self.b.find_element('xpath', '//*[@text="静态"]', 5)
        self.assertTrue(d)
        d = self.b.find_element('xpath', '//*[@text="编辑"]', 5)
        self.assertTrue(d)
        self.b.close_app()

    def test_c_feedback(self):
        "意见反馈功能"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        '点击我的'
        self.b.click_button('xpath', '//*[@text="我的"]')
        '校验我的页面内容呈现'
        d = self.b.find_element('xpath', '//*[@text="未登录"]', 5)
        self.assertTrue(d)
        #     点击意见反馈
        self.b.click_button('xpath', '//*[@text="意见反馈"]')
        #     校验反馈页信息
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/edit_des"]', 5)
        self.assertTrue(d)
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/add_image"]', 5)
        self.assertTrue(d)
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/edit_connect"]',
            5)
        self.assertTrue(d)
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/btn_commit"]', 5)
        self.assertTrue(d)
        # 输入反馈内容并提交
        self.b.send_keys('xpath',
                         '//*[@resource-id="com.vlocker.locker:id/edit_des"]',
                         '测试数据测试')
        self.b.send_keys(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/edit_connect"]',
            '123456')
        self.b.click_button('xpath', '//*[@text="提交"]')
        self.b.close_app()

    def test_d_make(self):
        "已登录用户制作主题"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        '点击我的'
        self.b.click_button('xpath', '//*[@text="我的"]')
        '校验我的页面内容呈现'
        d = self.b.find_element('xpath', '//*[@text="未登录"]', 5)
        self.assertTrue(d)
        # 消息通知
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_message"]',
            5)
        self.assertTrue(d)
        # 制作主题
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_diy_theme"]', 5)
        self.assertTrue(d)
        d.click()
        # 登录页  输入用户名密码登录
        self.assertTrue(self.b.find_element('xpath', '//*[@text="登录"]', 5))
        # 输入用户名密码登录
        self.driver.find_element_by_id(
            "com.vlocker.locker:id/edt_name").send_keys("1501149580200")
        self.driver.find_element_by_id(
            "com.vlocker.locker:id/edt_password").send_keys("moxiutest1234")
        self.b.click_button(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/btn_login"]')
        sleep(2)
        # 登录后直接到导入视频页
        self.assertTrue(self.b.find_element('xpath', '//*[@text="导入视频"]', 5))
        self.b.click_button(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/tv_next"]')
        self.assertTrue(self.b.find_element('xpath', '//*[@text="裁剪视频"]', 5))
        self.b.click_button(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/tv_next"]')
        self.assertTrue(self.b.find_element('xpath', '//*[@text="选择封面"]', 10))
        self.b.click_button('xpath', '//*[@text="发布"]')
        # 到发布主题页选择分类后发布
        self.assertTrue(self.b.find_element('xpath', '//*[@text="主题发布"]', 10))
        self.driver.find_element_by_id(
            "com.vlocker.locker:id/edt_theme_name").send_keys("帅哥")
        # 选择分类
        self.b.click_button('xpath', '//*[@text="选择一个分类"]')
        sleep(1)
        self.b.click_button('xpath', '//*[@text="男明星"]')
        sleep(1)
        self.b.click_button(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/ll_go_labspage"]')
        # 添加标签
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/ll_labs_containt"]', 5)
        self.assertTrue(d)
        self.driver.find_element_by_id(
            "com.vlocker.locker:id/ll_labs_containt").send_keys("帅哥")
        self.b.click_button('xpath', '//*[@text="确定"]')
        d = self.b.find_element('xpath', '//*[@text="保存到本地"]', 5)
        self.assertTrue(d)
        self.b.click_button('xpath', '//*[@text="保存到本地"]')
        d = self.b.find_element('xpath', '//*[@text="查看本地主题"]', 5)
        d = self.b.find_element('xpath', '//*[@text="应用该主题"]', 5)
        self.assertTrue(d)
        self.b.close_app()

    def test_e_myfav(self):
        "我的收藏"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        '点击我的'
        self.b.click_button('xpath', '//*[@text="我的"]')
        # 消息通知
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_message"]',
            5)
        self.assertTrue(d)
        # 点击我的收藏
        self.b.click_button('xpath', '//*[@text="我的收藏"]')
        # 校验收藏页信息
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_collect"]',
            5)
        self.assertTrue(d)
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/tool_bar_back"]',
            5)
        self.assertTrue(d)
        self.b.close_app()

    def test_f_mylike(self):
        "我的关注"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        '点击我的'
        self.b.click_button('xpath', '//*[@text="我的"]')
        # 消息通知
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_message"]',
            5)
        self.assertTrue(d)
        # 点击我的关注
        self.b.click_button('xpath', '//*[@text="我的关注"]')
        # 校验关注页信息,没有关注时
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/follow_icon"]',
            10)
        self.assertTrue(d)
        self.b.close_app()

    def test_g_myinfo(self):
        "我的信息"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        '点击我的'
        self.b.click_button('xpath', '//*[@text="我的"]')
        # 消息通知
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_message"]',
            5)
        self.assertTrue(d)
        # 校验我的信息
        # 头像
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/headerUserAvatar"]', 5)
        self.assertTrue(d)
        # 昵称
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_user_nickname"]', 5)
        self.assertTrue(d)
        # 签名
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_user_slogan"]', 5)
        self.assertTrue(d)
        # 点击到个人主页
        self.b.click_button(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/headerUserAvatar"]')
        # 查看主页信息
        # 获赞、下载量、作品、编辑按钮
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mineHomeHeaderL1"]', 5)
        self.assertTrue(d)
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/theme_list_title"]', 5)
        self.assertTrue(d)
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/tm_mine_edit_right"]', 5)
        self.assertTrue(d)
        self.b.close_app()

    def test_h_updateinfo(self):
        "修改个人信息"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        '点击我的'
        self.b.click_button('xpath', '//*[@text="我的"]')
        # 消息通知
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_message"]',
            5)
        self.assertTrue(d)
        # 校验我的信息
        # 头像
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/headerUserAvatar"]', 5)
        self.assertTrue(d)
        self.b.click_button(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/headerUserAvatar"]')
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/tm_mine_edit_right"]', 5)
        self.assertTrue(d)
        d.click()
        # 修改个人资料
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_profile_cover"]', 5)
        self.assertTrue(d)
        # 修改昵称
        self.b.click_button(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_profile_nickname"]')
        # self.b.send_keys('xpath', '//*[@resource-id="com.vlocker.locker:id/mine_profile_nickname"]', 'qqqd')
        # self.driver.find_element_by_id("com.vlocker.locker:id/mine_profile_nickname").send_keys("改个昵称")
        # 保存
        self.b.click_button(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/tv_save"]')
        # 保存后返回到用户主页
        self.driver.keyevent(4)
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/tm_mine_edit_right"]', 5)
        self.assertTrue(d)
        # 恢复昵称
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/tm_mine_edit_right"]', 5)
        self.assertTrue(d)
        d.click()
        # 修改个人资料
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/mine_profile_cover"]', 5)
        self.assertTrue(d)
        self.b.close_app()

    def test_i_logout(self):
        "退出登录"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        '点击我的'
        self.b.click_button('xpath', '//*[@text="我的"]')
        # 消息通知
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/mine_message"]',
            5)
        self.assertTrue(d)
        self.b.logout()
        self.b.close_app()

    def tearDown(self):
        AppiumSetup.tearDownClass()
Пример #3
0
class MediaTest(unittest.TestCase):
    "视频页内容验证"

    def setUp(self):
        AppiumSetup().setUpClass(get_version='7.1.1', device_name='cea8dc6c')
        self.driver = AppiumSetup().driver
        self.b = BasePage.Base()
        self.h = FunctionHelper.Function()

    def test_a_active_media(self):
        "互动主题页功能"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 5)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 5))
        '点击互动主题'
        self.b.click_button('xpath','//*[@text="互动主题"]')
        '互动主题页信息校验'
        self.assertTrue(self.b.find_element('xpath', '//*[@text="动态主题"]', 5))
        self.assertTrue(self.b.find_element('xpath','//*[@class="android.widget.ImageButton"]', 5))
        '上滑主题列表'
        self.b.swipe_up(5)
        '校验元素不存在'
        self.b.isElement("name", "陈立农唱歌给你听")
        '点击到主题详情页'
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/iv_spine_list_item"]', 10)
        '校验详情页内容'
        # 主题名称
        self.assertTrue(self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/tv_theme_title"]', 5))
        # 主题星级下载量
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/rb_theme"]', 5))
        self.assertTrue(self.b.find_element('xpath', '//*[@text="下载量:"]', 10))
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_theme_download_num"]', 5))
        # 主题描述
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_theme_desc"]', 10))
        '下载后应用'
        a = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/video_progress_down"]', 5)
        self.assertTrue(a)
        a.click()
        sleep(15)
        # 加判断,是否已经下载, 如果已经下载,则点击直接应用,如果没下载的,还需要再点击一次
        if self.b.isElement("resource-id", "com.vlocker.locker:id/video_progress_down"):
            a = self.driver.find_element_by_id("com.vlocker.locker:id/video_progress_down")
            a.click()
        else:
            print("已经下载,直接应用到桌面了")
            sleep(3)
        # a = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/video_progress_down"]', 5)
        # self.assertTrue(a)
        # a.click()
        # self.assertTrue(a)
        self.b.swipe_up(1)
        self.b.close_app()

    def test_b_rank(self):
        "排行榜功能"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 5)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 5))
        '点击排行榜'
        self.b.click_button('xpath','//*[@text="排行榜"]')
        #查看排行榜页面内容
        d=self.b.find_element('xpath','//*[@text="下载排行榜真香→_→"]',10)
        self.assertTrue(d)
    #     上传视频入口
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_video_upload"]', 10)
        self.assertTrue(d)
        self.b.close_app()

    def test_c_like(self):
        "普通视频壁纸点赞"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 5))
        '点击视频点赞'
        # 点击热门第一个视频
        # 找到父节点然后找子节点,按照下标找对应的text
        d = self.driver.find_element_by_id("com.vlocker.locker:id/mainView")
        e = d.find_elements_by_class_name("android.widget.FrameLayout")
        sleep(2)
        e[1].click()
        '校验视频页信息'
        d = self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/app_down"]', 5)
        self.assertTrue(d)
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/video_progress_down"]', 5)
        self.assertTrue(d)
        # 用户头像
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/video_img_user"]', 5)
        self.assertTrue(d)
        # 视频名称
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/video_text_title"]', 5)
        self.assertTrue(d)
        # 视频标签内容
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/video_layout_tag"]', 5)
        self.assertTrue(d)
        # 视频时长
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/desc_time"]', 5)
        self.assertTrue(d)
        # 视频大小
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/video_layout_tag"]', 5)
        self.assertTrue(d)
        # 视频有声
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/desc_sound"]', 5)
        self.assertTrue(d)
        # 视频大小
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/desc_size"]', 5)
        self.assertTrue(d)
        # 视频下载次数
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/desc_down"]', 5)
        self.assertTrue(d)
        '点赞视频-跳转登录'
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/video_img_like"]')
        # 登录页  输入用户名密码登录
        self.assertTrue(self.b.find_element('xpath','//*[@text="登录"]',10))
        # 输入用户名密码登录
        self.driver.find_element_by_id("com.vlocker.locker:id/edt_name").send_keys("1501149580200")
        self.driver.find_element_by_id("com.vlocker.locker:id/edt_password").send_keys("moxiutest1234")
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/btn_login"]', 2)
        # 登录成功后跳转到视频页
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/fab_share"]', 5))
        # 点赞状态
        d = self.driver.find_element_by_id("com.vlocker.locker:id/video_img_like")
        #d = self.driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.vlocker.locker:id/video_img_like")')
        d = d.is_selected()
        # if self.assertFalse(d):
            # 点赞
        self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/video_img_like"]')
        # else :
        #     print("已经点赞过,查看是否状态为已点赞")
        # 校验点赞成功
        d = self.driver.find_element_by_id("com.vlocker.locker:id/video_img_like")
        d=d.is_selected()
        self.assertTrue(d)
        self.b.close_app()

    def test_d_fav(self):
        "普通视频壁纸收藏"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 5))
        # 点击热门第一个视频
        # 找到父节点然后找子节点,按照下标找对应的text
        d = self.driver.find_element_by_id("com.vlocker.locker:id/mainView")
        e = d.find_elements_by_class_name("android.widget.FrameLayout")
        e[1].click()
        '校验视频页信息'
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/app_down"]', 5)
        self.assertTrue(d)
        # 判断收藏状态是否已收藏
        d = self.driver.find_element_by_id("com.vlocker.locker:id/video_img_collection")
        d = d.is_selected()
        # if self.assertFalse(d):
        #     # 点赞
        self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/video_img_collection"]')
        # else:
        #     print("已经点赞过,查看是否状态为已点赞")
        # 校验点赞成功
        # d=self.driver.find_element_by_android_uiautomator('new UiSelector().resourceId("com.vlocker.locker:id/video_img_like")')
        # self.assertTrue(d)
        sleep(3)
        d = self.driver.find_element_by_id("com.vlocker.locker:id/video_img_collection")
        d = d.is_selected()
        self.assertTrue(d)
        self.b.close_app()

    def test_e_usevlocker(self):
        "视频锁屏应用"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 5))
        # 上滑后点击视频
        # 找到父节点然后找子节点,按照下标找对应的text
        self.b.swipe_up(4)
        d = self.driver.find_element_by_id("com.vlocker.locker:id/mainView")
        e = d.find_elements_by_class_name("android.widget.FrameLayout")
        e[1].click()
        '校验视频页信息'
        d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/app_down"]', 5)
        self.assertTrue(d)
        '应用到锁屏'
        d = self.driver.find_element_by_id("com.vlocker.locker:id/video_progress_down")
        d.click()
        sleep(20)
        # 加判断,是否已经下载, 如果已经下载,则点击直接应用,如果没下载的,还需要再点击一次
        if self.b.isElement("resource-id","com.vlocker.locker:id/video_progress_down"):
            e = self.driver.find_element_by_id("com.vlocker.locker:id/video_progress_down")
            e.click()
        else:
            print("已经下载,直接应用到桌面")
            sleep(3)
        '判断是否应用到锁屏'
        self.assertTrue(self.b.find_element('xpath', '//*[@text="滑动以解锁"]', 10))
        self.b.swipe_right(1)
        self.b.close_app()

    def test_f_typefollow(self):
        "视频分类关注"
        d = self.b.find_element('xpath', '//*[@text="热门"]',10)
        self.assertTrue(d)
        d =self.b.find_element('xpath','//*[@text="分类"]',2)
        d.click()
        # 点击某个分类到详情页
        self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/tag_icon"]')
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/like_btn"]', 5))
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/layout_title"]', 5))
        '点击关注'
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/like_btn"]', 10)
        '关注后关注按钮变成取消关注'
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/like_btn_cancel"]', 5))
        '返回我的关注查看'
        self.driver.keyevent(4)
        self.b.click_button('xpath','//*[@text="我的"]')
        '点击我的关注查看'
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/mine_follow"]')
    #     我的关注有信息
        self.assertTrue(self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/follow_btn_follow"]',5))
    #     点击已关注按钮取消关注
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/follow_btn_follow"]')
        sleep(2)
        e = self.driver.find_element_by_id("com.vlocker.locker:id/follow_btn_unfollow").text
        self.assertEqual(e,"关注")
        self.driver.keyevent(4)
        self.b.close_app()

    def test_g_sharemedia(self):
        "视频分享"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/title"]', 5))
        # 找到父节点然后找子节点,按照下标找对应的text
        d = self.driver.find_element_by_id("com.vlocker.locker:id/mainView")
        e = d.find_elements_by_class_name("android.widget.FrameLayout")
        e[1].click()
        '点击分享'
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/fab_share"]')
    #     分享路径
        self.assertTrue(self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/mx_share_layout"]', 6))
    #     点击分享到qq
        self.b.click_button('xpath','//*[@text="QQ"]')
        sleep(2)
        # 发送
        self.b.click_button('xpath','//*[@text="魔秀大树"]')
        d=self.b.find_element('xpath','//*[@resource-id="com.tencent.mobileqq:id/dialogRightBtn"]',10)
        d.click()
    #     成功后点击回到微锁屏
    #     self.assertTrue(self.b.find_element('xpath','//*[@text="已发送"]',10))
        sleep(3)
        self.b.click_button('xpath','//*[@text="返回微锁屏"]')
        self.driver.keyevent(4)
        self.b.close_app()

    def tearDown(self):
        AppiumSetup.tearDownClass()
Пример #4
0
class TopicTest(unittest.TestCase):
    "主题页功能验证"

    def setUp(self):
        AppiumSetup().setUpClass(get_version='7.1.1', device_name='cea8dc6c')
        self.driver = AppiumSetup().driver
        self.b = BasePage.Base()
        self.h = FunctionHelper.Function()

    def test_a_topictype(self):
        self.b.totopic()
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/cardItemContainer"]', 10))
        # 点击全部分类
        self.b.click_button('xpath','//*[@text="全部分类"]')
        # 完整分类页内容呈现
        self.assertTrue(self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/tagsContainer"]',10))
        self.assertTrue(self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/subTagsContainer"]',10))
        # 找到父节点然后找子节点,按照下标找对应的text
        # 点击分类的第n个类别
        d = self.driver.find_element_by_id("com.vlocker.locker:id/tagsContainer")
        e = d.find_elements_by_id("com.vlocker.locker:id/tagName")
        e[4].click()
        # 再点击第一个子类
        f=self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/tagIcon"]',10)
        f.click()
        #查看分类详情页
        self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/listContainer"]',10)
        # 页面点击第9张主题图
        d=self.driver.find_elements_by_id("com.vlocker.locker:id/cardImagebg")
        d[8].click()
        self.b.close_app()

    def test_b_topicdetails(self):
        "主题详情页"
        self.b.totopic()
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/cardItemContainer"]', 10))
    #     点击分类中某一个进去到主题详情
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/imageView"]')
        d=self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/cardImagebg"]',10)
        d.click()
        # 查看详情页信息
        self.assertTrue(self.b.find_element('xpath','//*[@resource-id="com.vlocker.locker:id/rv_theme_preview"]',10))
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_title"]', 10))
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/view_theme_tag"]', 10))
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_download_count"]', 10))
        self.b.close_app()

    def test_c_topic_apply(self):
        "主题应用"
        self.b.totopic()
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/cardItemContainer"]', 10))
        #     点击分类中某一个进去到主题详情
        self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/imageView"]')
        d = self.b.find_elements('xpath', '//*[@resource-id="com.vlocker.locker:id/cardImagebg"]', 10)
        d[2].click()
        # 查看详情页信息
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/rv_theme_preview"]', 10))
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_title"]', 10))
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/view_theme_tag"]', 10))
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_download_count"]', 10))
        # 点击下载按钮
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/theme_progress_down"]')
        sleep(3)
        # 点击应用
        # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/theme_progress_down"]')
    #     校验是否已应用锁屏
        self.assertTrue(self.b.isElement('text','滑动以解锁'))
        self.b.close_app()

    def test_d_topic_search(self):
        "主题搜索"
        self.b.totopic()
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/cardItemContainer"]', 10))
        # 搜索框输入主题关键字搜索
        '''点击搜索框到搜索页面'''
        self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/search"]')
        '等待页面加载'
        a = self.b.find_element('xpath', '//*[@text="搜索"]', 10)
        self.assertTrue(a)
        # 输入关键字搜索
        self.driver.find_element_by_id("com.vlocker.locker:id/search_edittext").send_keys("霍建华")
        self.b.click_button('xpath', '//*[@text="搜索"]')
        # 校验跳转页是主题搜索页
        e = self.b.find_element('xpath', '//*[@text="综合"]', 10)
        self.assertTrue(e)
        # 点击第一个主题图
        self.b.click_button('xpath','//*[@resource-id="com.vlocker.locker:id/image_layout"]')
        self.b.close_app()

    def test_e_topic_share(self):
        "主题分享"
        self.b.totopic()
        # 判断数据加载
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/cardItemContainer"]', 10))
        #     点击分类中某一个进去到主题详情
        self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/imageView"]')
        d = self.b.find_elements('xpath', '//*[@resource-id="com.vlocker.locker:id/cardImagebg"]', 10)
        d[2].click()
        # 查看详情页信息
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/rv_theme_preview"]', 10))
        '点击分享'
        self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/fab_share"]')
        #     分享路径
        self.assertTrue(self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/mx_share_layout"]', 6))
        #     点击分享到qq
        self.b.click_button('xpath', '//*[@text="QQ"]')
        sleep(2)
        # 发送
        self.b.click_button('xpath', '//*[@text="魔秀大树"]')
        d = self.b.find_element('xpath', '//*[@resource-id="com.tencent.mobileqq:id/dialogRightBtn"]', 10)
        d.click()
        #     成功后点击回到微锁屏
        # self.assertTrue(self.b.find_element('xpath', '//*[@text="已发送"]', 10))
        sleep(3)
        self.b.click_button('xpath', '//*[@text="返回微锁屏"]')
        self.driver.keyevent(4)
        sleep(1)
        self.driver.keyevent(4)
        sleep(2)
        self.b.click_button('xpath','//*[@text="我的"]')
        '在当前类最后一个用例后退出登录'
        '退出登录'
        # self.b.logout()
        self.b.close_app()

    def tearDown(self):
        AppiumSetup.tearDownClass()
Пример #5
0
class ToolTest(unittest.TestCase):
    "工具页基础功能"

    def setUp(self):
        AppiumSetup().setUpClass(get_version='7.1.1', device_name='cea8dc6c')
        self.driver = AppiumSetup().driver
        self.b = BasePage.Base()
        self.h = FunctionHelper.Function()

    def test_a_tool_default(self):
        "工具页整体内容"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(
            self.b.find_element(
                'xpath', '//*[@resource-id="com.vlocker.locker:id/title"]',
                10))
        # 点击到工具页
        self.b.click_button('xpath', '//*[@text="工具"]')
        # 页面呈现,
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/tool_header_progress"]',
                10))
        self.b.close_app()

    def test_b_tool_lock(self):
        "锁屏功能"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 5)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(
            self.b.find_element(
                'xpath', '//*[@resource-id="com.vlocker.locker:id/title"]',
                10))
        # 点击到工具页
        self.b.click_button('xpath', '//*[@text="工具"]')
        # 页面呈现,
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/tool_first_line"]',
                10))
        self.b.click_button('xpath', '//*[@text="锁屏功能"]')
        sleep(2)
        #锁屏功能页面
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/setting_msg_layout"]',
                10))
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/setting_music_layout"]',
                10))
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/setting_toolbox_layout"]',
                10))
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/setting_weather_item"]',
                10))
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/setting_music_check"]',
                10))
        # self.b.swipe_up(1)
        d = self.b.find_element('xpath', '//*[@text="延迟锁屏"]', 10)
        self.assertTrue(d)
        self.b.close_app()

    @AppiumSetup.add
    def test_c_tool_applock(self):
        "应用锁功能校验"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(
            self.b.find_element(
                'xpath', '//*[@resource-id="com.vlocker.locker:id/title"]',
                10))
        # 点击到工具页
        self.b.click_button('xpath', '//*[@text="工具"]')
        # 页面呈现,
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/tool_first_line"]',
                10))
        self.b.click_button('xpath', '//*[@text="应用锁"]')
        #         查看应用锁默认页面
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/l_app_select_count"]',
                10))
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/app_selected"]', 10))
        self.assertTrue(
            self.b.find_element(
                'xpath', '//*[@resource-id="com.vlocker.locker:id/app_hot"]',
                10))
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/app_sort_desc"]', 10))
        #       点击下一步
        self.b.click_button('xpath', '//*[@text="下一步"]')
        # 设置密码页查看
        self.assertTrue(self.b.find_element('xpath', '//*[@text="使用数字密码"]',
                                            10))
        self.b.click_button('xpath', '//*[@text="使用数字密码"]')
        self.assertTrue(self.b.find_element('xpath', '//*[@text="设置密码位数"]',
                                            10))
        #         点击下一步
        self.b.click_button('xpath', '//*[@text="下一步>"]')
        #         密码设置com.vlocker.locker:id/locknum
        d = self.driver.find_element_by_id("com.vlocker.locker:id/locknum")
        e = d.find_elements_by_id("android.widget.TextView")
        sleep(3)
        self.b.click_button('xpath', '//*[@text="1"]')
        self.b.click_button('xpath', '//*[@text="2"]')
        self.b.click_button('xpath', '//*[@text="3"]')
        self.b.click_button('xpath', '//*[@text="4"]')
        #         再次输入
        self.assertTrue(self.b.find_element('xpath', '//*[@text="请重复密码"]', 10))
        self.b.click_button('xpath', '//*[@text="1"]')
        self.b.click_button('xpath', '//*[@text="2"]')
        self.b.click_button('xpath', '//*[@text="3"]')
        self.b.click_button('xpath', '//*[@text="4"]')
        sleep(2)
        # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')
        # sleep(2)
        # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')
        #         到密码保护页,只有首次安装app之后才会有密保输入
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/tv_question"]', 10))
        self.b.click_button('xpath', '//*[@text="生日是?"]')
        sleep(3)
        # c = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]', 10)
        # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')
        # self.assertTrue(c)
        # c.click()
        os.system('adb shell input tap 228 1887')
        sleep(2)
        self.assertTrue(self.b.find_element('xpath', '//*[@text="应用锁"]', 10))
        sleep(2)
        self.b.click_button('xpath', '//*[@text="应用锁"]')
        self.b.click_button('xpath', '//*[@text="1"]')
        self.b.click_button('xpath', '//*[@text="2"]')
        self.b.click_button('xpath', '//*[@text="3"]')
        self.b.click_button('xpath', '//*[@text="4"]')
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/setting_enable_applock_img"]',
                10))
        # 返回桌面点击图库
        # self.driver.keyevent(3)
        # sleep(3)
        # # 启动相册查看
        # cmd = "adb shell am start -W -n  com.vivo.gallery/com.android.gallery3d.vivo.GalleryTabActivity "
        # self.content = os.popen(cmd)
        # sleep(2)
        # # 校验应用锁设置生效
        # self.assertTrue(
        #     self.b.find_element('xpath', '//*[@text="输入密码"]', 10))
        self.b.close_app()

    def test_d_restartlock(self):
        "重启锁屏"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        self.b.click_button('xpath', '//*[@text="我的"]')
        d = self.b.find_element('xpath', '//*[@text="设置"]', 10)
        d.click()
        # 关闭锁屏开关
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/close_lock_check"]', 10)
        d.click()
        # 点击开启锁屏
        d = self.b.find_element(
            'xpath', '//*[@resource-id="com.vlocker.locker:id/start_lock"]',
            10)
        d.click()
        self.b.close_app()

    @AppiumSetup.add
    def test_e_lockpassword(self):
        "锁屏密码设置应用"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 10)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(
            self.b.find_element(
                'xpath', '//*[@resource-id="com.vlocker.locker:id/title"]',
                10))
        # 点击到工具页
        self.b.click_button('xpath', '//*[@text="工具"]')
        # 点击锁屏密码
        self.b.click_button('xpath', '//*[@text="锁屏密码"]')
        d = self.b.find_element('xpath', '//*[@text="密码设置"]', 5)
        self.assertTrue(d)
        # 点击设置数字密码
        d = self.b.find_element(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/setting_enable_num_locker_img"]',
            10)
        d.click()
        sleep(2)
        # 下一步
        d = self.b.find_element('xpath', '//*[@text="下一步>"]', 10)
        d.click()
        d = self.b.find_element('xpath', '//*[@text="4位密码"]', 5)
        self.assertTrue(d)
        sleep(3)
        self.b.click_button('xpath', '//*[@text="1"]')
        self.b.click_button('xpath', '//*[@text="2"]')
        self.b.click_button('xpath', '//*[@text="3"]')
        self.b.click_button('xpath', '//*[@text="4"]')
        #         再次输入
        self.assertTrue(self.b.find_element('xpath', '//*[@text="请重复密码"]', 10))
        self.b.click_button('xpath', '//*[@text="1"]')
        self.b.click_button('xpath', '//*[@text="2"]')
        self.b.click_button('xpath', '//*[@text="3"]')
        self.b.click_button('xpath', '//*[@text="4"]')
        # sleep(2)
        # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/tv_question"]')
        # sleep(2)
        # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')
        # # 查看密码类型
        # d = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/tool_bar_title"]', 10)
        # self.assertTrue(d)
        sleep(2)
        # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')
        # sleep(2)
        # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')
        #         到密码保护页,只有首次安装app之后才会有密保输入
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/tv_question"]', 10))
        self.b.click_button('xpath', '//*[@text="生日是?"]')
        sleep(3)
        # c = self.b.find_element('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]', 10)
        # self.b.click_button('xpath', '//*[@resource-id="com.vlocker.locker:id/btn_question_ok"]')
        # self.assertTrue(c)
        # c.click()
        os.system('adb shell input tap 228 1887')
        sleep(2)
        # 灭屏亮屏查看锁屏应用
        self.driver.lock(1)
        # self.driver.unlock()
        # 点亮屏幕
        cmd = 'adb shell input keyevent 26'
        os.popen(cmd)
        sleep(2)
        # 右滑解锁
        self.b.swipe_right(1)
        sleep(2)
        # 当前密码锁屏页校验
        d = self.b.find_element('xpath', '//*[@text="输入密码"]', 5)
        self.assertTrue(d)
        d = self.b.find_element('xpath', '//*[@text="美化密码"]', 5)
        self.assertTrue(d)
        self.b.close_app()

    @AppiumSetup.add
    def test_f_unlocknum(self):
        "解锁数字密码锁屏"
        d = self.b.find_element('xpath', '//*[@text="热门"]', 5)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(
            self.b.find_element(
                'xpath', '//*[@resource-id="com.vlocker.locker:id/title"]',
                10))
        # 灭屏亮屏查看锁屏应用
        self.driver.lock(1)
        # self.driver.unlock()
        cmd = 'adb shell input keyevent 26'
        os.popen(cmd)
        sleep(3)
        # 右滑解锁
        self.b.swipe_right(1)
        sleep(2)
        d = self.b.find_element('xpath', '//*[@text="美化密码"]', 5)
        self.assertTrue(d)
        #     解锁
        self.b.click_button('xpath', '//*[@text="1"]')
        self.b.click_button('xpath', '//*[@text="2"]')
        self.b.click_button('xpath', '//*[@text="3"]')
        self.b.click_button('xpath', '//*[@text="4"]')
        d = self.b.find_element('xpath', '//*[@text="互动主题"]', 5)
        self.assertTrue(d)
        self.b.close_app()

    @AppiumSetup.add
    def test_g_change_nopassword(self):
        " 密码切换无密码锁屏 "
        d = self.b.find_element('xpath', '//*[@text="热门"]', 5)
        self.assertTrue(d)
        # 判断数据加载
        self.assertTrue(
            self.b.find_element(
                'xpath', '//*[@resource-id="com.vlocker.locker:id/title"]',
                10))
        #     点击工具
        self.b.click_button('xpath', '//*[@text="工具"]')
        # 页面呈现,
        self.assertTrue(
            self.b.find_element(
                'xpath',
                '//*[@resource-id="com.vlocker.locker:id/tool_first_line"]',
                10))
        # 锁屏密码页
        sleep(3)
        self.b.click_button('xpath', '//*[@text="锁屏密码"]')
        #     输入原密码
        self.assertTrue(self.b.find_element('xpath', '//*[@text="输入原密码"]', 10))
        sleep(2)
        self.b.click_button('xpath', '//*[@text="1"]')
        self.b.click_button('xpath', '//*[@text="2"]')
        self.b.click_button('xpath', '//*[@text="3"]')
        self.b.click_button('xpath', '//*[@text="4"]')
        #     到密码设置页选择无密码
        self.assertTrue(self.b.find_element('xpath', '//*[@text="密码设置"]', 10))
        # 点击无密码
        self.b.click_button(
            'xpath',
            '//*[@resource-id="com.vlocker.locker:id/setting_none_layout"]')
        # 校验是否已经切换到无密码
        a = self.b.isElement('text', '个性设置')
        self.assertTrue(a)
        self.b.close_app()

    def tearDown(self):
        AppiumSetup.tearDownClass()