class LoginTest(unittest.TestCase): content = Utility.get_json('../conf/yang/testinfo.conf') login_info = Utility.tran_tuple(content[0]) @classmethod def setUpClass(cls): warnings.simplefilter('ignore', ResourceWarning) def setUp(self): self.driver = Service.get_driver('../conf/yang/base.conf') self.driver.implicitly_wait(15) self.driver.maximize_window() from lib.login import Login self.login = Login(self.driver) def tearDown(self): self.driver.close() @classmethod def tearDownClass(cls): pass #测试登录 @parameterized.expand(login_info) def test_login(self, uname, psword, code, expect): self.login.do_login(uname, psword, code, '../conf/yang/base.conf') # time.sleep(25) from selenium.webdriver.common.by import By #如果存在注销链接 time.sleep(3) if Service.is_element_present(self.driver, By.PARTIAL_LINK_TEXT, "修改密码"): actual = "login-success" #退出系统 self.login.click_logout() else: actual = "login-fail" time.sleep(1) # Utility.get_error_png(self.driver) self.assertEqual(actual, expect)
class LoginTest(unittest.TestCase): login_conf = Utility.get_json('..\\conf\\testinfo.conf')[0] login_info = Utility.trans_tuple(login_conf) @classmethod def setUpClass(cls): pass @classmethod def tearDownClass(cls): pass def setUp(self): from lib.login import Login from tools.service import Service self.login = Login(Service.get_session()) def tearDown(self): pass @parameterized.expand(login_info) def test_login(self, url, method, uname, upass, vcode, expect): warnings.simplefilter('ignore', ResourceWarning) login_test_info = { 'URL': url, 'METHOD': method, 'LOGINDATA': { 'username': uname, 'password': upass, 'verifycode': vcode }, 'EXPECT': expect } login_resp = self.login.do_login(login_test_info['URL'], login_test_info['METHOD'], login_test_info['LOGINDATA']) result = login_resp.text if result == 'login-pass': actual = 'login-pass' elif result == 'login-fail': actual = 'login-fail' else: actual = 'vcode-error' self.assertEqual(actual, login_test_info['EXPECT'])