标签:用户 code __file__ pre list pwd forum 登录 name
1 from page.LoginPage import Loginpage 2 import os, sys, pytest 3 4 base_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) 5 sys.path.append(base_dir) 6 7 8 class TestLogin(): 9 10 @pytest.mark.parametrize( 11 "name, password", 12 [(‘admin‘, ‘admin‘), 13 (‘jack‘, ‘123456‘), 14 (‘abc‘, ‘123456‘) 15 ], 16 ids=[‘admin登录成功‘, ‘jack登录成功‘, ‘用户名错误失败‘] 17 ) 18 def test_case(self, browser, name, password, base_url=None): 19 obj = Loginpage(browser) 20 obj.get("http://192.168.117.9:8080/jforum/forums/list.page") 21 obj.user_bix.send_keys(name) 22 obj.pwd_bix.send_keys(password) 23 obj.submit.click() 24 if name != "abc": 25 assert obj.assert_succeed.text == "个人资料" 26 obj.userout.click() 27 else: 28 assert obj.assert_fialed.text == "您输入了无效的用户名或错误的密码" 29 30 31 if __name__ == "__main__": 32 pass
pytest.mark.parametrize()参数化的应用一
标签:用户 code __file__ pre list pwd forum 登录 name
原文地址:https://www.cnblogs.com/97xiaolai/p/11811961.html