Skip to content

Instantly share code, notes, and snippets.

@flufftronix
Created April 5, 2022 03:58
Show Gist options
  • Save flufftronix/16cca99385d2cbcccebfa89c50799371 to your computer and use it in GitHub Desktop.
Save flufftronix/16cca99385d2cbcccebfa89c50799371 to your computer and use it in GitHub Desktop.
For automating the download of My Green Button data from PECO
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
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 pyshadow.main import Shadow
import time
options = Options()
options.headless = True
driver = webdriver.Chrome(options=options)
shadow = Shadow(driver)
driver.get('https://secure.peco.com/accounts/login')
wait = WebDriverWait(driver, 10)
wait.until(EC.title_is('Sign up or sign in'))
user = driver.find_element_by_id("signInName")
user.send_keys('USERNAME-HERE')
password = driver.find_element_by_id("password")
password.send_keys('PASSWORD-HERE')
nextButton = driver.find_element_by_xpath('//*[@id ="next"]')
nextButton.click()
wait2 = WebDriverWait(driver, 10)
wait2.until(EC.title_is('Accounts'))
driver.get('https://secure.peco.com/MyAccount/MyBillUsage/pages/secure/MyBillDetails.aspx')
wait3 = WebDriverWait(driver, 10)
wait3.until(EC.title_contains('My Bill Details'))
my_usage = driver.find_element_by_link_text('My Usage')
my_usage.click()
time.sleep(3)
driver.find_element_by_id('MSOZoneCell_WebPartWPQ6').click()
wait4 = WebDriverWait(driver, 10)
wait4.until(EC.title_contains("My Green Button Data"))
time.sleep(5)
shadow.find_element(".green-button").click()
time.sleep(1)
shadow.find_elements('.custom-radio')[3].click()
shadow.find_element('.primary').click()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment