mport time
from selenium.webdriver.common.by import By
from selenium import webdriver
# 创建一个 Chrome WebDriver 实例
driver = webdriver.Chrome()
# 打开登录页面
driver.get('http://192.168.3.1/html/index.html#/home')
# 等待
time.sleep(2)
# 查找用户名和密码输入框,并输入相应的信息
password_input = driver.find_element(By.ID, 'userpassword_ctrl')
# 输入密码
password_input.send_keys("15975580898")
# 等待
time.sleep(2)
# 查找登录按钮,并点击
login_button = driver.find_element(By.XPATH, "//*[@id='loginbtn']")
login_button.click()
# 等待
time.sleep(2)
# 更多功能
login_button1 = driver.find_element(By.XPATH, "//*[@id='more']/div")
login_button1.click()
# 等待
time.sleep(2)
# wifi设置
login_button2 = driver.find_element(By.XPATH, "//*[@id='wifisettingsparent_menuId']")
login_button2.click()
# 等待
time.sleep(2)
# 选择信道 2.4G
script = "document.getElementById('wifi_channel24g_ctrl_selectlist_parenselect').innerText = '2';"
driver.execute_script(script)
# 等待
time.sleep(2)
# 选择模式 2.4G
script = "document.getElementById('wlan_mode_ctrl_selectlist_parenselect').innerText = '802.11b';"
driver.execute_script(script)
# 等待
time.sleep(2)
# 选择信道 5G
script = "document.getElementById('wifi_channel5g_ctrl_selectlist_parenselect').innerText = '36';"
driver.execute_script(script)
# 等待
time.sleep(2)
# 保存
login_button = driver.find_element(By.XPATH, "//*[@id='SendSettings_submitbutton']")
login_button.click()
# 等待
time.sleep(2)
# 程序暂停,不关闭浏览器
input("点击任意键继续...")
# 关闭浏览器
driver.quit()
1.密码输入框ID查找
3.模式下拉框设置,Copy--->Copy XPath 获得“//*[@id="wlan_mode_ctrl_selectlist_parenselect"]
———————————————
熟悉Labview、Python、VBA、C、Excel公式、PCB Layout、PIC单片机等,欢迎沟通讨论
部分文档为做项目过程中的源代码,可能没有注释,有疑问欢迎私信沟通
#电子爱好者 #电子专业 #从事硬件自动测试开发