from selenium import webdriver import time
from selenium import webdriver from selenium.webdriver.support.ui import Select from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.common.by import By from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.action_chains import ?ActionChains import time import os ? ? ??
def selenium_log_in_action(): ? ? """ ? ? """ ? ? ? AP_WEBADMIN_username="admin" ? ? AP_WEBADMIN_password="123456" ? ? wd = webdriver.Chrome() ? ? ? ? wd.implicitly_wait(5)
? ? wd.get("http://router.asus.com/")
? ? # wd.minimize_window() ? ? username_ele = wd.find_element_by_xpath('//input[@id="login_username"]') ? ? username_ele.send_keys(AP_WEBADMIN_username) ? ? password_ele = wd.find_element_by_xpath('//input[@type="password"]') ? ? password_ele.send_keys(AP_WEBADMIN_password) ? ? login_button = wd.find_element_by_xpath('//div[@class="button"]') ? ? login_button.click() ? ? wireless_setup_ele = wd.find_element_by_xpath("//div[@id='Advanced_Wireless_Content_menu']") ? ? wireless_setup_ele.click()
? ? return wd ?? def ?ch_24(): ? ? ?wd=selenium_log_in_action() ? ? try: ? ? ? ? i = 0 ? ? ? ? while 1:
? ? ? ? ? ? fb_ele = Select(wd.find_element_by_xpath('//*[@id="WLgeneral"]/tbody/tr[11]/td/select')) ? ? ? ? ? ? fb_ele.select_by_index(str(i)) ? ? ? ? ? ? time.sleep(1) ? ? ? ? ? ? wd.find_element_by_id("applyButton").click() ? ? ? ? ? ? result=EC.alert_is_present()(wd) ? ? ? ? ? ? if result: ? ? ? ? ? ? ? ?wd.switch_to.alert.accept() ? ? ? ? ? ? i = i + 1 ? ? ? ? ? ? if i>=13: ? ? ? ? ? ? ? ? i=0 ? ? ? ? ? ? time.sleep(20) ? ? except: ? ? ? ? wd.__exit__()
? ? continue
|