python Gece ben uyurken 10 dakikada bir modemi resetleyip yeni bir IP alacakbirşeylazımdı。 Kullanımı

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python Gece ben uyurken 10 dakikada bir modemi resetleyip yeni bir IP alacakbirşeylazımdı。 Kullanımı相关的知识,希望对你有一定的参考价值。

from selenium import webdriver
from selenium.common.exceptions import TimeoutException
from selenium.webdriver.support.ui import WebDriverWait # available since 2.4.0
from selenium.webdriver.support import expected_conditions as EC # available since 2.26.0
from selenium.webdriver.common.by import By

# Create a new instance of the Firefox driver
driver = webdriver.Chrome()
# go to the google home page
driver.get("http://192.168.1.1/")

# the page is ajaxy so the title is originally this:
print driver.title

# find the element that's name attribute is q (the google search box)
inputElement = driver.find_element_by_id("index_username")
# type in the search
# inputElement.send_keys("admin")

password = driver.find_element_by_id("password")
password.send_keys("xxxxxxxxxxxxxxxxxxxxxxxxx")

# submit the form (although google automatically searches now without submitting)

driver.execute_script("Atp.LoginController.postData();")
maintain_div = driver.find_element_by_xpath('//*[@id="maintain_settings_menu"]/div')
maintain_div.click()

# driver.get("http://192.168.1.1/html/advance.html")
# driver.execute_script("location.href = http://192.168.1.1/html/advance.html#device_info")
# driver.execute_script('document.querySelector("#i18n-7").click()')

try:
    # we have to wait for the page to refresh, the last thing that seems to be updated is the title
    WebDriverWait(driver, 5).until(EC.title_contains("HG658"))
    # You should see "cheese! - Google Search"
    driver.get("http://192.168.1.1/html/advance.html#device_mngt")
    print driver.title
finally:
  # driver.quit()
  pass


# WebDriverWait(driver, 5).until(EC.title_contains("xxxxxx"))
# driver.execute_script("location.href = http://192.168.1.1/html/advance.html#device_info")

try:
  wait = WebDriverWait(driver, 5)
  element = wait.until(EC.element_to_be_clickable((By.ID,'i18n-22')))
  driver.get('http://192.168.1.1/html/advance.html#device_mngt')

  element = wait.until(EC.element_to_be_clickable((By.ID,'rebootId')))
  # reboot = driver.find_element_by_id("rebootId")
  # reboot.submit()

  driver.execute_script('document.querySelector("#rebootId").click();')
  wait.until(EC.element_to_be_clickable( (By.ID, 'dev_mngt_modal_id_ok')))
  dev_mngt_modal_id_ok = driver.find_element_by_id('dev_mngt_modal_id_ok')
  # driver.execute_script('window.alert()')

  driver.execute_script("dev_mngt_modal_id_ok.click()")


finally:
  # driver.quit()
  pass

以上是关于python Gece ben uyurken 10 dakikada bir modemi resetleyip yeni bir IP alacakbirşeylazımdı。 Kullanımı的主要内容,如果未能解决你的问题,请参考以下文章

仅匹配单词(有时用点分隔)正则表达式

ruby ben_multi.rb

ruby ben_singleton.rb

质量王者局820丨Swift, Snow, Ben, Thal, Pirean, Cheong

HTML HTML5 base clean - Ben Wellby

python-列表