Esempio n. 1
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()
Esempio n. 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()
Esempio n. 3
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(), "你还没有输入密码!")
Esempio n. 4
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(), "你还没有输入帐号!")
Esempio n. 5
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()), '登录失败!'
Esempio n. 6
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(), "你输入的帐号或密码不正确,请重新输入。")
Esempio n. 7
0
    def test1_img_nick_is_displayed(self):
        """检测登录控件是否会有快捷登录的相关信息并且显示是否正确"""
        qq_login()

        self.driver.get("https://mail.qq.com/")
        sleep(3)
        self.driver.switch_to.frame("login_frame")
        result_1 = self.driver.find_element_by_id(
            "img_out_1414710823").is_displayed()
        result_2 = self.driver.find_element_by_id(
            "nick_1414710823").is_displayed()
        if result_1 and result_2:
            # qq昵称显示是否正确
            text = self.driver.find_element_by_id("nick_1414710823").text
            self.assertEqual(text, "老④")
            # 截图查看快捷登录按钮的图片以及鼠标悬浮显示的账号是否有异常
            loc = (By.ID, "img_out_1414710823")
            mouseover(self.driver, *loc)
            get_screenshot(self.driver,
                           "./mail_auto_test/report/img/quick_login.jpg")
Esempio n. 8
0
    def test_forget_password(self):
        """测试点击“忘了密码”后页面跳转是否正确"""
        # 打开登录页面,并获取窗口句柄:handle1
        self.driver.get("https://mail.qq.com/")
        handle1 = self.driver.current_window_handle

        # 打开忘记密码窗口,并获取所有窗口的句柄handles
        self.driver.switch_to.frame("login_frame")
        self.driver.find_element_by_id('forgetpwd').click()
        sleep(3)  # 这个地方必须加睡眠时间,给新窗口打开预留时间,不然马上执行下面的代码结束测试
        handles = self.driver.window_handles

        # 筛选窗口句柄切换到忘记密码窗口,并判断页面是否正确
        for handle in handles:
            if handle != handle1:
                self.driver.switch_to_window(handle)
                text = self.driver.title
                assert (text == "重置密码 - QQ安全中心")
                sleep(1)
                get_screenshot(
                    self.driver,
                    "./mail_auto_test/report/img/forget_password.jpg")