예제 #1
0
 def test_func(self, get_driver):
     '''注册、忘记密码等链接是否正确'''
     print("测试注册、忘记密码等链接是否正确..."),
     with allure.step('初始化浏览器driver'):
         login_page = LoginPage(get_driver)
     with allure.step('打开登陆界面'):
         login_page.open_login()
     with allure.step('点击忘记密码,确认跳到密码重置页面'):
         login_page.click_by_id("forgetpwd")
         time.sleep(3)
         # 获得当前窗口句柄集合
         handles = login_page.driver.window_handles
         for handle in handles:
             if handle != login_page.driver.current_window_handle:
                 login_page.driver.switch_to.window(handle)
                 break
         assert "重置" in login_page.driver.title
         login_page.driver.close()
         # 切回主窗口
         login_page.driver.switch_to.window(handles[0])
     with allure.step("点击注册,进入注册页面"):
         login_page.click_by_xpath(
             "//a[@href='http://zc.qq.com/chs/index.html?type=1']")
         time.sleep(3)
         # 获得当前窗口句柄集合
         handles = login_page.driver.window_handles
         for handle in handles:
             if handle != login_page.driver.current_window_handle:
                 login_page.driver.switch_to.window(handle)
                 break
         assert "注册" in login_page.get_source()
         login_page.driver.close()
         # 切回主窗口
         login_page.driver.switch_to.window(handles[0])
         time.sleep(1)
예제 #2
0
 def test_login_correct(self, get_driver):
     '''登陆后跳转到正确页面'''
     print("测试登陆后跳转到正确页面..."),
     with allure.step('初始化浏览器driver'):
         login_page = LoginPage(get_driver)
     with allure.step('打开登陆界面,输入正确的用户名,密码'):
         login_page.login(self.user, self.correct_pwd, False)
     with allure.step('界面中包含邮箱首页'):
         assert "邮箱首页" in login_page.get_source()
예제 #3
0
 def test_login_fail(self, get_driver):
     '''输入错误的用户名/密码'''
     print("测试错误用户名/密码登陆...")
     with allure.step('初始化浏览器driver'):
         login_page = LoginPage(get_driver)
     with allure.step('打开登陆界面,输入错误的用户名/密码'):
         login_page.login(self.user, "any", False)
     with allure.step('提示用户名/密码错误'):
         assert "账号或密码不正确" in login_page.get_source()
예제 #4
0
 def test_pwd_with_capslock(self, get_driver):
     '''测试大写开启提示'''
     print("测试大写开启提示..."),
     with allure.step('初始化浏览器driver'):
         login_page = LoginPage(get_driver)
     with allure.step('打开登陆界面,开启大写锁定输入密码'):
         login_page.open_login()
         login_page.driver.find_element_by_id("p").send_keys(Keys.CAPS)
         login_page.driver.find_element_by_id("p").send_keys("test")
         time.sleep(3)
     with allure.step('判断存在大写锁定提示'):
         assert "大写锁定" in login_page.get_source()
예제 #5
0
 def test_login_emptycheck(self, get_driver):
     '''非空检查'''
     print("测试对于用户名/密码非空检查...")
     with allure.step('初始化浏览器driver'):
         login_page = LoginPage(get_driver)
     with allure.step('打开登陆界面'):
         login_page.open_login()
     with allure.step('什么都不输入,点击登录'):
         # 登录且不等待
         login_page.login_submit(False)
     with allure.step('界面提示输入用户名'):
         assert "输入账号" in login_page.get_source()
     with allure.step('只输入用户名,点击登录'):
         login_page.input_user_pwd(self.user, "")
         login_page.login_submit(False)
     with allure.step('界面提示输入密码'):
         assert "输入密码" in login_page.get_source()
     with allure.step('只输入密码,点击登录'):
         login_page.input_user_pwd("", "123456")
         login_page.login_submit(False)
     with allure.step('界面提示输入用户名'):
         assert "输入账号" in login_page.get_source()