Last active
December 17, 2015 15:59
-
-
Save millimoose/5635561 to your computer and use it in GitHub Desktop.
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
import os | |
from os import path | |
from selenium import webdriver | |
from selenium.webdriver import ActionChains | |
from selenium.webdriver.common.by import By | |
from selenium.common.exceptions import NoSuchElementException | |
CSS = By.CSS_SELECTOR | |
def do_login(ff): | |
""" | |
:param ff: webdriver.Firefox | |
""" | |
print "Logging in" | |
txtUsername = ff.find_element(CSS, 'input[id$=_txtUsername]') | |
txtPassword = ff.find_element(CSS, 'input[id$=_txtPassword]') | |
btnLogin = ff.find_element(CSS, 'a[id$=_btnLogin]') | |
txtUsername.send_keys(HOST_USERNAME) | |
txtPassword.send_keys(HOST_PASSWORD) | |
btnLogin.click() | |
def upload_package(ff): | |
""" | |
:param ff: webdriver.Firefox | |
""" | |
print "Uploading extension package" | |
cmdBrowse = ff.find_element(CSS, 'input[id$=_cmdBrowse]') | |
package_path = path.join(path.dirname(__file__), 'obj', 'AIS.Extranet.UserDefinedTable_Install.zip') | |
cmdBrowse.send_keys(path.abspath(package_path)) | |
ff.find_element(CSS, 'a[id$=_nextButtonStart]').click() | |
def click_through(ff): | |
""" | |
:param ff: webdriver.Firefox | |
""" | |
# Upload Results | |
try: | |
ff.find_element(CSS, 'input[id$=_chkRepairInstall]').click() | |
print "Need to repair install" | |
ff.find_element(CSS, 'a[id$=_nextButtonStep]').click() | |
except NoSuchElementException: | |
print "No need to repair" | |
pass | |
print "Clicking through wizard" | |
# Package Information | |
ff.find_element(CSS, 'a[id$=_nextButtonStep]').click() | |
# Release Notes | |
ff.find_element(CSS, 'a[id$=_nextButtonStep]').click() | |
# Review License | |
ff.find_element(CSS, 'input[id$=_chkAcceptLicense]').click() | |
ff.find_element(CSS, 'a[id$=_nextButtonStep]').click() | |
def main(): | |
try: | |
ff = webdriver.Firefox() | |
ac = ActionChains(ff) | |
ff.get(LOGIN_URL) | |
ff.implicitly_wait(60) | |
do_login(ff) | |
# Hover over "Host" link. | |
ac.move_to_element(ff.find_element(CSS, 'a[href*="/Host/tabid/"]')) | |
ac.perform() | |
# Go to extension wizard | |
ff.find_element(CSS, 'a[href*="/Host/Extensions/tabid/"]').click() | |
ff.find_element(By.PARTIAL_LINK_TEXT, 'Install Extension Wizard').click() | |
upload_package(ff) | |
click_through(ff) | |
print "Install done, saving log" | |
install_log = ff.find_element(CSS, '.dnnInstallLogs > table').text | |
with open(path.join(path.dirname(__file__), 'Deploy.log'), 'w') as log_out: | |
log_out.write(install_log) | |
finally: | |
raw_input('Press ENTER to continue') | |
ff.close() | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment