admin管理员组

文章数量:1530953

前提:公司的路由器密码忘记了,试了好多个没对,懒得手动测试,然后想试试python+selenium的网页自动操作功能,参考了某大神的教程,结果如下:

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdrivermon.by import By
import time
url = 'http://192.168.xx.1/webpages/login.html' #配置测试地址
wd = webdriver.Chrome() #调用chrome,这里将chromedriver.exe放入python目录中,不用路径调用
wd.get(url)
f = open(r'e:/passwd1.txt') #配置密码文件路径
for i in f.readlines():
    time.sleep(1) #等待页面刷新
    input_account = wd.find_element(By.ID,'username')
    input_account.send_keys('admin') #使用固定用户admin
    i = i.strip('\n')
    input_password = wd.find_element(By.XPATH,'//*[@type="password"]')
    input_password.send_keys(i)
    login_button = wd.find_element(

本文标签: 路由器账号密码Pythonselenium