Last active
February 14, 2016 05:38
-
-
Save kurozumi/a44a4e7022ddcf759f73 to your computer and use it in GitHub Desktop.
【Python】Seleniumを使ってA8.netのプログラム契約解除を自動化する
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding:utf-8 | |
from selenium import webdriver | |
from selenium.webdriver.common.keys import Keys | |
from selenium.webdriver.common.action_chains import ActionChains | |
from selenium.webdriver.common.alert import Alert | |
driver = webdriver.Firefox() | |
driver.implicitly_wait(10) | |
driver.get("http://www.a8.net") | |
username = driver.find_element_by_name("login") | |
username.send_keys("username") | |
password = driver.find_element_by_name("passwd") | |
password.send_keys("password") | |
button = driver.find_element_by_name("lgin_as_btn") | |
button.click() | |
while True: | |
try: | |
# プログラム管理をクリック | |
menu = driver.find_element_by_css_selector("#globalMenuWrap") | |
submenu = driver.find_element_by_xpath("/html/body/div[1]/div[1]/div[2]/ul/li[3]/ul/li[1]/a"); | |
actions = ActionChains(driver) | |
actions.move_to_element(menu) | |
actions.click(submenu) | |
actions.perform() | |
#プログラム詳細ボタンクリック | |
button = driver.find_element_by_xpath("/html/body/div[2]/div/div/form[2]/div/div[2]/div[3]/table[1]/tbody/tr[1]/td[6]/table/tbody/tr[2]/td/a"); | |
button.click() | |
#契約解除メニュークリック | |
button = driver.find_element_by_xpath("/html/body/div[2]/div/div/div/div/div/ul/li[4]/a"); | |
button.click() | |
#契約解除ボタンクリック | |
button = driver.find_element_by_xpath("/html/body/div[2]/div/div/form/div/div[2]/a"); | |
button.click() | |
#契約解除に同意する | |
Alert(driver).accept() | |
#トップへ戻る | |
button = driver.find_element_by_xpath("/html/body/div[3]/a"); | |
button.click() | |
except: | |
driver.close() | |
driver.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment