Пример #1
0
 def test4_wrong_password(self):
     """错误密码登录测试"""
     num = str(random.randint(0, 199))
     pl = PageLogin(self.driver)
     pl.test_login(num + "*****@*****.**", num * 3)
     sleep(3)
     self.assertEqual(pl.login_error(), "你输入的帐号或密码不正确,请重新输入。")
Пример #2
0
 def test_giant_attachment(self):
     """添加超大附件发送邮件流程测试"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进行email发送操作
     pse = PageSendMail(self.driver)
     # 进入写信页面
     pse.goto_letter()
     # 切换到iframe表单mainFrame
     self.driver.switch_to.frame("mainFrame")
     # 添加收信人地址,可以添加多个,请按[email protected];的格式添加
     pse.type_receiver("[email protected];", "[email protected];")
     # 添加主题
     pse.type_subject("python selenium send email test")
     # 添加附件
     pse.upload_attachment3(
         r"F:\Git_lib\python_selenium\QQ_mail_auto_test\package\result.html"
     )
     # 添加正文
     body_text = "hello! this is email test!" \
                 "upload_giant_attachment"
     pse.type_mail_body(body_text)
     # 发送邮件
     pse.type_send()
     sleep(3)
     # 检测邮件发送或是否成功
     get_screenshot(self.driver, "./mail_auto_test/report/img/login_ok.jpg")
     pse.send_success_hint()
Пример #3
0
    def test_save_as_draft(self):
        """写信存为草稿测试"""
        # 快捷登录网页
        pl = PageLogin(self.driver)
        pl.quick_login()
        # 进行email发送操作
        pse = PageSendMail(self.driver)
        # 进入写信页面
        pse.goto_letter()
        # 定位到“草稿箱”,并获取到初始数字;(测试此项前,草稿箱至少要有草稿;此种验证不可靠可以不采用)
        text_1 = self.driver.find_element_by_id("folder_4").text
        num_1 = re.search("\d+", text_1).group()
        # 切换到iframe表单mainFrame
        self.driver.switch_to.frame("mainFrame")
        # 点击“存草稿”按钮
        pse.type_save_draft()
        time.sleep(1)
        # 第一种验证根据页面提示
        # self.driver.switch_to.default_content()
        # now = time.strftime("%H:%M")
        # assert(pse.get_message_box(1) == now + " 邮件成功保存到草稿箱"), "未保存成功"

        # 第二种验证根据左侧导航列表“草稿箱”后面的数字做判断,在添加草稿前就要获取一次然后存为操作后再次获取一次,判断是否增加。此种验证可以用到正则表达式去获取数字
        # 再次定位“草稿箱”,并获取数字
        self.driver.switch_to.default_content()
        text_2 = self.driver.find_element_by_id("folder_4").text
        num_2 = re.search("\d+", text_2).group()
        assert (num_2 > num_1), "未保存成功"
Пример #4
0
 def test1_auto_login_next(self):
     """勾选【下次自动登录】登录测试"""
     pl = PageLogin(self.driver)
     pl.auto_login()
     sleep(3)
     self.driver.switch_to.default_content()
     assert (self.text == pl.login_success_hint()), '登录失败!'
Пример #5
0
 def test3_write_out(self):
     """添加了邮件主题或正文,关闭写信页面,且将改动存为草稿"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进行email发送操作
     pse = PageSendMail(self.driver)
     # 进入写信页面
     pse.goto_letter()
     # 切换到iframe表单mainFrame
     self.driver.switch_to.frame("mainFrame")
     # 添加主题
     pse.type_subject("python selenium send email test")
     # 关闭写信
     pse.type_exit()
     time.sleep(2)
     # 对提示框进行选择:是
     self.driver.switch_to.default_content()
     pse.select_leave_tip(1)
     time.sleep(1)
     # 是否保存为草稿
     now = time.strftime("%H:%M")
     assert (pse.get_message_box(1) == now + " 邮件成功保存到草稿箱"), "未保存成功"
     time.sleep(1)
     # 通过页面的title来验证页面是否跳转了
     assert (self.driver.title == "QQ邮箱"), "写信未关闭"
Пример #6
0
 def test_send_mail(self):
     """发送邮件的最基本流程测试"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进行email发送操作
     pse = PageSendMail(self.driver)
     # 进入写信页面
     pse.goto_letter()
     # 切换到iframe表单mainFrame
     self.driver.switch_to.frame("mainFrame")
     # 添加收信人地址,可以添加多个,请按[email protected];的格式添加
     pse.type_receiver("[email protected];", "[email protected];")
     # 添加主题
     pse.type_subject("python selenium send email test subject")
     # 添加正文
     body_text = "hello! this is email test!" \
                 "thanks"
     pse.type_mail_body(body_text)
     # 发送邮件
     pse.type_send()
     sleep(3)
     # 检测邮件发送或是否成功
     get_screenshot(self.driver, "./mail_auto_test/report/img/login_ok.jpg")
     pse.send_success_hint()
Пример #7
0
 def test3_null_password(self):
     """测试空密码登录"""
     num = str(random.randint(0, 199))
     pl = PageLogin(self.driver)
     pl.test_login(num + "*****@*****.**", "")
     sleep(3)
     self.assertEqual(pl.login_error(), "你还没有输入密码!")
Пример #8
0
 def test_null_password(self):
     """测试空密码登录"""
     pl = PageLogin(self.driver)
     pl.test_login(self.num + "*****@*****.**", "")
     sleep(3)
     get_screenshot(self.driver,
                    "./mail_auto_test/report/img/null_password_login.jpg")
     self.assertEqual(pl.login_error(), "你还没有输入密码!")
Пример #9
0
 def test_login_ok(self):
     """正确的用户名和密码登录测试"""
     pl = PageLogin(self.driver)
     pl.test_login()
     self.driver.switch_to.default_content()
     sleep(3)
     get_screenshot(self.driver, "./mail_auto_test/report/img/login_ok.jpg")
     assert(self.text == pl.login_success_hint()), '登录失败!'
Пример #10
0
 def test5_login_ok(self):
     """正确的用户名和密码登录测试"""
     text = '*****@*****.**'
     pl = PageLogin(self.driver)
     pl.test_login()
     self.driver.switch_to.default_content()
     sleep(3)
     assert (text == pl.login_success_hint()), '登录失败!'
Пример #11
0
 def test_null_username(self):
     """测试空户名和空密码登录"""
     pl = PageLogin(self.driver)
     pl.test_login("", "")
     sleep(3)
     get_screenshot(self.driver,
                    "./mail_auto_test/report/img/null_username_login1.jpg")
     self.assertEqual(pl.login_error(), "你还没有输入帐号!")
Пример #12
0
    def test_wrong_password(self):
        """错误密码登录测试"""

        pl = PageLogin(self.driver)
        pl.test_login(self.num + "*****@*****.**", self.num * 3)
        sleep(3)
        get_screenshot(self.driver,
                       "./mail_auto_test/report/img/wrong_password_login.jpg")
        self.assertEqual(pl.login_error(), "你输入的帐号或密码不正确,请重新输入。")
Пример #13
0
 def test3_next_auto_login(self):
     # 登录邮箱并勾选“下次自动登录”
     pl = PageLogin(self.driver)
     pl.auto_login()
     sleep(3)
     # 用pyautogui关闭浏览器,不给teardown清除环境的机会
     # 然后再次使用pyautogui打开网页去验证
     pyautogui.click(1893, 11)
     open_mail_web()
Пример #14
0
 def test4_mark_as_unread(self):
     """测试页面全部未读标记为已读"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 全部标记为已读
     self.driver.switch_to.frame("mainFrame")
     ree.set_all_readed()
     sleep(2)
     # 未读邮件统计
     ree.verify_no_unread()
Пример #15
0
 def test4_mark_as_unstar(self):
     """测试页面全部邮件标记为星标"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱,并全选
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     self.driver.switch_to.frame("mainFrame")
     ree.all_check()
     # 标记为星标邮件
     ree.mark_as_unstar()
     # 验证已标记为星标
     self.driver.switch_to.default_content()
     assert (ree.star_mail_statistics() == "0"), "标记星标邮件失败"
Пример #16
0
 def test1_write_out(self):
     """未添加任何邮件内容,关闭写信页面"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进行email发送操作
     pse = PageSendMail(self.driver)
     # 进入写信页面
     pse.goto_letter()
     # 点击关闭
     self.driver.switch_to.frame("mainFrame")
     pse.type_exit()
     time.sleep(1)
     # 通过页面的title来验证页面是否跳转了
     assert (self.driver.title == "QQ邮箱"), "写信未关闭"
Пример #17
0
 def test3_mark_as_unstar(self):
     """测试按发件人姓名将邮件标记为星标"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 按发件人姓名勾选
     self.driver.switch_to.frame("mainFrame")
     ree.check_by_sender("罗江华", 0)
     # 标记为星标邮件
     ree.mark_as_unstar()
     # 验证已标记为星标
     self.driver.switch_to.default_content()
     assert (ree.star_mail_statistics() == "0"), "标记星标邮件失败"
Пример #18
0
 def test2_mark_as_unstar(self):
     """测试随机批量邮件标记为星标"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 随机批量勾选:暂定三个
     self.driver.switch_to.frame("mainFrame")
     ree.check_multi(0)
     # 标记为星标邮件
     ree.mark_as_unstar()
     # 验证已标记为星标
     self.driver.switch_to.default_content()
     assert (ree.star_mail_statistics() <= "21"), "标记星标邮件失败"
Пример #19
0
 def test1_mark_as_unstar(self):
     """测试随机单个邮件标记为星标"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 随机勾选一个邮件
     self.driver.switch_to.frame("mainFrame")
     ree.single_check(0)
     # 标记为星标邮件
     ree.mark_as_unstar()
     # 验证已标记为星标
     self.driver.switch_to.default_content()
     assert (ree.star_mail_statistics() == "24"), "标记星标邮件失败"
Пример #20
0
 def test3_mark_as_unread(self):
     """按发件人姓名标记为未读"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 按发件人姓名勾选
     self.driver.switch_to.frame("mainFrame")
     ree.check_by_sender("罗江华", 0)
     # 标记为未读
     ree.mark_as_unread()
     sleep(2)
     # 未读邮件统计
     assert (self.driver.find_element_by_id("_ur_c").text == "25"), "标记未读失败"
Пример #21
0
 def test2_mark_as_unread(self):
     """测试随机批量未读标记为已读"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 随机批量勾选:暂定三个
     self.driver.switch_to.frame("mainFrame")
     ree.check_multi(1)
     # 标记为未读
     ree.mark_as_read()
     sleep(2)
     # 未读邮件统计
     assert (self.driver.find_element_by_id("_ur_c").text == "21"), "标记未读失败"
Пример #22
0
 def test4_mark_as_unread(self):
     """测试页面全部已读标记为未读"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 勾选全部已读
     self.driver.switch_to.frame("mainFrame")
     ree.check_mode(2)
     # 标记为未读
     ree.mark_as_unread()
     sleep(2)
     # 未读邮件统计
     assert (self.driver.find_element_by_id("_ur_c").text == "25"), "标记未读失败"
Пример #23
0
 def test3_quick_login(self):
     """点击快捷登录控件的QQ昵称是否能登陆成功"""
     self.driver.get("https://mail.qq.com/")
     sleep(3)
     self.driver.switch_to.frame("login_frame")
     # 检测元素是否存在,不存在则
     result = self.driver.find_element_by_id(
         "nick_1414710823").is_displayed()
     if result:
         self.driver.find_element_by_id("nick_1414710823").click()
         self.driver.switch_to.default_content()
         sleep(5)
         PageLogin(self.driver)
         assert ("*****@*****.**" == PageLogin(
             self.driver).login_success_hint()), "点击昵称,快捷登录失败"
     else:
         raise ElementNotPresent("定位的元素不存在")
Пример #24
0
 def test1_mark_as_unread(self):
     """测试随机单个已读标记为未读"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 随机勾选一个邮件
     self.driver.switch_to.frame("mainFrame")
     ree.single_check(0)
     # 标记为未读
     ree.mark_as_unread()
     sleep(2)
     # 未读邮件统计
     # TODO:这里的定位之后可以考虑移到page里
     assert (self.driver.find_element_by_id("_ur_c").text == "1"), "标记未读失败"
Пример #25
0
 def test1_single_delete(self):
     """随机勾选一个信件进行删除"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 随机勾选一个邮件
     self.driver.switch_to.frame("mainFrame")
     ree.single_check(0)
     # 删除勾选的邮件
     ree.del_email()
     sleep(2)
     # 删除会出现提示
     self.driver.switch_to.default_content()
     assert (ree.get_message_box() == "删除成功 [撤销]"), "未删除成功"
Пример #26
0
 def test2_batch_del(self):
     """随机批量删除"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 随机批量勾选:暂定三个
     self.driver.switch_to.frame("mainFrame")
     ree.check_multi(0)
     # 删除勾选的邮件
     ree.del_email()
     sleep(2)
     # 删除会出现提示
     self.driver.switch_to.default_content()
     assert (ree.get_message_box() == "删除成功 [撤销]"), "未删除成功"
Пример #27
0
 def test3_del_by_sender(self):
     """按发件人姓名勾选删除"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 按发件人姓名勾选
     self.driver.switch_to.frame("mainFrame")
     ree.check_by_sender("罗江华", 0)
     # 删除勾选的邮件
     ree.del_email()
     sleep(1)
     # 删除会出现提示
     self.driver.switch_to.default_content()
     assert (ree.get_message_box() == "删除成功 [撤销]"), "未删除成功"
Пример #28
0
 def test4_del_all(self):
     """全部勾选删除"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 全部勾选
     self.driver.switch_to.frame("mainFrame")
     ree.all_check()
     # 删除勾选的邮件
     ree.del_email()
     sleep(1)
     # 删除会出现提示
     self.driver.switch_to.default_content()
     assert (ree.get_message_box() == "删除成功 [撤销]"), "未删除成功"
Пример #29
0
 def qtest3_send_no_body(self):
     """未添加主题点击发送(预期:可以发送)"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进行email发送操作
     pse = PageSendMail(self.driver)
     # 进入写信页面
     pse.goto_letter()
     self.driver.switch_to.frame("mainFrame")
     # 添加收信人地址,可以添加多个,请按[email protected];的格式添加
     pse.type_receiver("[email protected];", "[email protected];")
     # 添加主题
     pse.type_subject("python selenium send email test subject")
     # 发送邮件
     pse.type_send()
     sleep(3)
     # 检测邮件发送或是否成功
     pse.send_success_hint()
Пример #30
0
 def test4_del_all(self):
     """全部勾选彻底删除"""
     # 快捷登录网页
     pl = PageLogin(self.driver)
     pl.quick_login()
     # 进入收件箱
     ree = ReceiveEmail(self.driver)
     ree.goto_inbox()
     # 全部勾选
     self.driver.switch_to.frame("mainFrame")
     ree.all_check()
     # 删除勾选的邮件
     ree.completely_del_email()
     # 删除会出现提示
     self.driver.switch_to.default_content()
     ree.prompt_confirmation(0)
     assert (ree.get_message_box() == "删除成功 [撤销]"), "未删除成功"
     # 切换到已删除目录,查看彻底删除的邮件是否存在
     ree.verify_complete_deletion()