def test_user_too_long(self, get_driver): '''测试用户名/密码过长''' print("测试输入用户名/密码过长..."), with allure.step('初始化浏览器driver'): login_page = LoginPage(get_driver) with allure.step('打开登陆界面,输入20位用户名和密码'): login_page.open_login() user = "******" * 20 login_page.input_user_pwd(user, user) with allure.step('输入的用户名小于20位'): if len(login_page.get_element_attr("u", "value")) < 20: pass else: pytest.fail("输入用户名长度没有限制") with allure.step('输入的密码小于20位'): if len(login_page.get_element_attr("p", "value")) < 20: pass else: pytest.fail("输入密码长度没有限制")
def test_pwd_hidden_show(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("testpassword") time.sleep(1) with allure.step('判断密码是否加星显示'): assert "password" == login_page.get_element_attr("p", "type")