import itertools
#迭代器,用来生成密码
passwd = ("".join(x) for x in itertools.product("0a", repeat=10)) #迭代器,生成密码
def test_violenceLogin(self):
#测试错误登陆的次数限制(防止暴力破解)
while True:
# 先直接实现,然后再添加异常
try:
str = next(passwd)
print(str)
self.login('1060267971', str)
#print("86864733"+str)
sleep(1)
link = self.dr.find_element(By.CSS_SELECTOR, 'img.avatar-img')
print(link.text)
if('你好,'+str in link.text):
break
except StopIteration as e:
continue
except selenium.common.exceptions.ElementNotInteractableException as e2:
continue
except selenium.common.exceptions.NoSuchElementException as e3:
continue
print("密码已破解:" + str)
sleep(100)
欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) | Powered by Discuz! X3.2 |