标签:wait mis strong driver missing miss tag username menu
1 import unittest 2 from selenium import webdriver 3 from time import sleep 4 5 class lonInTest (unittest.TestCase): 6 @classmethod 7 def setUp(self): 8 self.driver = webdriver.Firefox() 9 self.driver.implicitly_wait(30) 10 def test_login_sucess(self): 11 self.login("XXXXX","XXXXXXX") 12 sleep(3) 13 logoutName = self.driver.find_element_by_class_name("menu-link-label") 14 self.assertTrue(‘修改密码‘ in logoutName.text) 15 16 def login(self, username, password): 17 self.driver.get("http:XXXXXXXXXX") 18 input_field = self.driver.find_element_by_name("username") 19 input_field.clear() 20 input_field.send_keys(username) 21 22 input_password = self.driver.find_element_by_name("password") 23 input_password.clear() 24 input_password.send_keys(password) 25 26 login = self.driver.find_element_by_tag_name("button") 27 login.click() 28 29 def tearDown(self): 30 self.driver.quit() 31 32 unittest.main()
作为一个刚开学习python+selenium+unnitest的小白人员,说一下我写这段代码遇到的问题吧
问题:运行程序就报TypeError: test_login() missing 2 required positional arguments: ‘username‘ and ‘password‘
后来经过种种排查发现:login函数之前的test去掉就可以了,因为login是内部调用的函数,test开头的是每一条用例
def test_login_sucess(self):
self.test_login("XXXXXX","XXXXXX")
sleep(3)
logoutName = self.driver.find_element_by_class_name("menu-link-label")
self.assertTrue(‘修改密码‘ in logoutName.text)
def test_login(self, username, password):
self.driver.get("XXXXXXXXXXXXX")
input_field = self.driver.find_element_by_name("username")
input_field.clear()
input_field.send_keys(username)
python+selenium+unnitest写一个完整的登陆的验证
标签:wait mis strong driver missing miss tag username menu
原文地址:https://www.cnblogs.com/jiyanjiao-702521/p/9117739.html