Beispiel #1
0
 def test_case_RegEr1(self):
     # 手机号为空时,点击获取验证码测试用例
     for x in range(1, 6):
         try:
             self.driver.find_element_by_id(getNumID).click()
             # 获取并验证失败的toast提示
             GetToast.find_toast(u'手机号码格式错误', 5, 0.1, self.driver)
             break
         except Exception, e:
             pass
Beispiel #2
0
    def test_case_RegEr2(self):
        self.driver.find_element_by_id(usernameID).send_keys(userNumText)
        self.driver.find_element_by_id(numID).send_keys('1231')
        self.driver.find_element_by_id(passwordID).send_keys(passwordText)
        time.sleep(2)
        self.driver.find_element_by_id(regID).click()
        GetToast.find_toast(u'验证验证码失败', 5, 0.1, self.driver)
        self.driver.find_element_by_id(passwordID).clear()

        print '验证码有误的情况,测试通过'
        time.sleep(3)
Beispiel #3
0
 def test_case_forgetPassEr2(self):
     self.driver.find_element_by_id(usernameID).send_keys(userNumText)
     self.driver.find_element_by_id(numID).send_keys('1231')
     self.driver.find_element_by_id(passwordID).send_keys(passwordText)
     for x in range(1, 11):
         try:
             self.driver.find_element_by_id(resetPasswordID).click()
             # 获取并验证登录错误的toast提示
             GetToast.find_toast(u'短信验证码格式不正确', 5, 0.1, self.driver)
             break
         except Exception, e:
             continue
Beispiel #4
0
    def test_case_forgetPassEr3(self):
        self.driver.find_element_by_id(passwordID).send_keys(passwordTextEr)
        self.driver.find_element_by_id(resetPasswordID).click()
        GetToast.find_toast(u'密码格式错误,只能包含数字,字母和特殊符号(6-16个字符)', 5, 0.1,
                            self.driver)
        self.driver.find_element_by_id(usernameID).clear()
        '''测试密码框明文显示及删除按扭功能'''
        # 获取密文文本为空
        text1 = self.driver.find_element_by_id(passwordID).text
        # 获取点击密码明文显示后的文本
        self.driver.find_element_by_id(view_passID).click()
        text2 = self.driver.find_element_by_id(passwordID).text
        # 判断密文与明文显示,不同则通过
        self.assertNotEqual(text1, text2)

        print '密码格式有误的情况及密码明文显示与删除,测试通过'
        time.sleep(2)
Beispiel #5
0
class ForgetPassTest(unittest.TestCase):
    global driver

    # 初始化环境
    @classmethod
    def setUpClass(cls):
        # 更改Appium启动参数
        appium_config.desired_caps['automationName'] = 'Uiautomator2'
        # 启动Appium
        appium_config.AppiumStart(cls)
        cls.extend = Appium_Extend(cls.driver)

        # 获取手机屏幕分辨率
        cls.x = cls.driver.get_window_size()['width']
        cls.y = cls.driver.get_window_size()['height']

        time.sleep(5)

        # 进入忘记密码页面
        cls.driver.find_element_by_id(Page_config.PageID.homeMy).click()
        cls.driver.find_element_by_id(Page_config.PageID.myLogin).click()
        time.sleep(2)
        cls.driver.find_element_by_id(
            Page_config.PageID.forgetPasswordID).click()

    # 退出测试
    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()

    # 手机号输入错误,重置密码失败的用例
    def test_case_forgetPassEr1(self):
        # 判断页面标题是否正确
        try:
            self.assertEqual(
                self.driver.find_element_by_id(
                    Page_config.PageID.titleID).text, u'找回密码')
        except Exception, e:
            pass
        while True:
            try:
                # 手机号为空时,点击获取验证码测试用例
                self.driver.find_element_by_id(getNumID).click()
                # 获取并验证失败的toast提示
                GetToast.find_toast(u'手机号码格式错误', 5, 0.1, self.driver)
                break
            except Exception, e:
                continue
Beispiel #6
0
    def test_case_CommentCase1(self):
        print '随机选择的漫画为:%s' % self.comic_name
        time.sleep(3)

        comment_num = self.driver.find_element_by_id(
            'com.xmtj.mkz:id/tv_comment_count').text
        comment_num_str = comment_num.encode("utf-8")
        comment_num1 = int("".join(filter(str.isdigit, comment_num_str)))
        self.driver.find_element_by_id(
            'com.xmtj.mkz:id/comment_layout').click()
        WebDriverWait(self.driver,
                      30).until(lambda driver: driver.find_element_by_id(
                          Page_config.PageID.titleID))
        comment_title = self.driver.find_element_by_id(
            Page_config.PageID.titleID).text
        element_comment_str = comment_title.encode("utf-8")
        element_comment_num = int("".join(
            filter(str.isdigit, element_comment_str)))
        # 判断评论数量大于99时,icon数字的显示是否正确
        if element_comment_num > 99:
            self.assertEqual(comment_num, u'99+')
        elif element_comment_num <= 99:
            self.assertEqual(element_comment_num, comment_num1)
        print '该漫画的评论数在漫画详情页显示为:%s,实际评论总数为:%d' % (comment_num,
                                                  element_comment_num)
        time.sleep(2)

        # 进入发表评论页面
        self.driver.find_element_by_xpath(
            '//android.widget.ImageView[contains(@index,1)]').click()
        WebDriverWait(self.driver,
                      30).until(lambda driver: driver.find_element_by_id(
                          'com.xmtj.mkz:id/btn_add_comment'))

        # 评论为空,发布按钮不能点击
        add_comment = self.driver.find_element_by_id(
            'com.xmtj.mkz:id/btn_add_comment')
        self.assertEqual(add_comment.get_attribute('clickable'), u'false')
        print '评论为空,发布按钮不能点击,测试通过'
        # 评论字数不足
        self.driver.find_element_by_id('com.xmtj.mkz:id/edit').send_keys(
            u'不错不')
        add_comment.click()
        GetToast.find_toast(u'评论内容必须在4-200个字符之间', 30, 0.1, self.driver)
        print '评论字数不符合规则,不能发布,测试通过'
        # 评论成功
        self.driver.find_element_by_id('com.xmtj.mkz:id/edit').send_keys(
            u'不错不错,加油大大!')
        add_comment.click()
        GetToast.find_toast(u'发布评论成功', 30, 0.1, self.driver)
        WebDriverWait(self.driver,
                      30).until(lambda driver: driver.find_element_by_id(
                          Page_config.PageID.titleID))
        time.sleep(2)
        comment_content_text1 = self.driver.find_element_by_id(
            'com.xmtj.mkz:id/comment_content').text
        self.assertEqual(comment_content_text1, u'不错不错,加油大大!')
        print '评论发布成功,测试通过'
        WebDriverWait(self.driver,
                      30).until(lambda driver: driver.find_element_by_id(
                          'com.xmtj.mkz:id/comment_content'))
        self.driver.find_element_by_id(
            'com.xmtj.mkz:id/comment_content').click()
        WebDriverWait(self.driver, 30).until(
            lambda driver: driver.find_element_by_id('com.xmtj.mkz:id/send'))
        # 回复为空不能点击发布
        reply_comment = self.driver.find_element_by_id('com.xmtj.mkz:id/send')
        self.assertEqual(reply_comment.get_attribute('enabled'), u'false')
        print '评论回复为空,发布按钮不能点击,测试通过'
        # 回复内容字数不符合规则
        self.driver.find_element_by_id('com.xmtj.mkz:id/edit').send_keys(
            u'666')
        reply_comment.click()
        GetToast.find_toast(u'评论内容必须在4-200个字符之间', 30, 0.1, self.driver)
        print '评论回复字数不符合规则,不能发布,测试通过'
        # 评论回复成功
        self.driver.find_element_by_id('com.xmtj.mkz:id/edit').send_keys(
            u'6666')
        reply_comment.click()
        GetToast.find_toast(u'回复评论成功', 30, 0.1, self.driver)
        print '评论回复发布成功,测试通过'
        for n in range(0, 2):
            self.driver.find_element_by_accessibility_id('转到上一层级').click()
            time.sleep(3)

        # 刷新漫画详情页
        x1 = 520.00 / 1080
        y1 = 300.00 / 1920
        y2 = 850.00 / 1920
        # 实际坐标
        x_swipe1 = int(x1 * self.x)
        y_swipe1 = int(y1 * self.y)
        y_swipe2 = int(y2 * self.y)
        self.driver.swipe(x_swipe1, y_swipe1, x_swipe1, y_swipe2, 3000)
        WebDriverWait(self.driver,
                      30).until(lambda driver: driver.find_element_by_id(
                          'com.xmtj.mkz:id/comment_layout'))

        # 判断评论本地是否缓存成功
        self.driver.find_element_by_id(
            'com.xmtj.mkz:id/comment_layout').click()
        WebDriverWait(self.driver,
                      30).until(lambda driver: driver.find_element_by_id(
                          'com.xmtj.mkz:id/comment_content'))
        comment_list1 = self.driver.find_elements_by_id(
            'com.xmtj.mkz:id/comment_content')
        comment_content = comment_list1[0].text
        self.assertEqual(comment_content, u'不错不错,加油大大!')
        print '评论本地缓存成功'

        # 进入评论详情页面
        comment_list1[0].click()
        time.sleep(3)
        comment_list2 = self.driver.find_elements_by_id(
            'com.xmtj.mkz:id/comment_content')
        reply_content = comment_list2[1].text
        self.assertEqual(reply_content, u'6666')
        print '评论回复本地缓存成功'
Beispiel #7
0
        except Exception, e:
            pass
        while True:
            try:
                # 手机号为空时,点击获取验证码测试用例
                self.driver.find_element_by_id(getNumID).click()
                # 获取并验证失败的toast提示
                GetToast.find_toast(u'手机号码格式错误', 5, 0.1, self.driver)
                break
            except Exception, e:
                continue

        # 手机号格式不为手机号码时,点击获取验证码测试用例
        self.driver.find_element_by_id(usernameID).send_keys(userNumTextEr2)
        self.driver.find_element_by_id(getNumID).click()
        GetToast.find_toast(u'手机号码格式错误', 5, 0.1, self.driver)
        self.driver.find_element_by_id(usernameID).clear()

        # 手机号格式少于11位时,点击获取验证码测试用例
        self.driver.find_element_by_id(usernameID).send_keys(userNumTextEr3)
        self.driver.find_element_by_id(getNumID).click()
        GetToast.find_toast(u'手机号码格式错误', 5, 0.1, self.driver)
        self.driver.find_element_by_id(usernameID).clear()

        # 手机号未注册时,点击获取验证码测试用例
        self.driver.find_element_by_id(usernameID).send_keys(userNumTextEr1)
        self.driver.find_element_by_id(getNumID).click()
        GetToast.find_toast(u'手机号还未注册', 5, 0.1, self.driver)
        self.driver.find_element_by_id(usernameID).clear()

        print '手机号输入有误的情况,测试通过'
Beispiel #8
0
    # 手机号输入错误,注册失败的用例
    def test_case_RegEr1(self):
        # 手机号为空时,点击获取验证码测试用例
        for x in range(1, 6):
            try:
                self.driver.find_element_by_id(getNumID).click()
                # 获取并验证失败的toast提示
                GetToast.find_toast(u'手机号码格式错误', 5, 0.1, self.driver)
                break
            except Exception, e:
                pass

        # 手机号格式不为手机号码时,点击获取验证码测试用例
        self.driver.find_element_by_id(usernameID).send_keys(userNumTextEr2)
        self.driver.find_element_by_id(getNumID).click()
        GetToast.find_toast(u'手机号码格式错误', 5, 0.1, self.driver)
        self.driver.find_element_by_id(usernameID).clear()

        # 手机号格式少于11位时,点击获取验证码测试用例
        self.driver.find_element_by_id(usernameID).send_keys(userNumTextEr3)
        self.driver.find_element_by_id(getNumID).click()
        GetToast.find_toast(u'手机号码格式错误', 5, 0.1, self.driver)
        self.driver.find_element_by_id(usernameID).clear()

        # 手机号已注册时,点击获取验证码测试用例
        self.driver.find_element_by_id(usernameID).send_keys(userNumTextEr1)
        self.driver.find_element_by_id(getNumID).click()
        GetToast.find_toast(u'手机号已经注册过', 5, 0.1, self.driver)
        self.driver.find_element_by_id(usernameID).clear()
        print '手机号输入有误的情况,测试通过'
        time.sleep(3)