import time import base64 from selenium import webdriver from selenium.webdriver.common.by import By from selenium.webdriver.support.ui import WebDriverWait from selenium.webdriver.support import expected_conditions as EC from selenium.webdriver.common.desired_capabilities import DesiredCapabilities from selenium.common.exceptions import UnexpectedAlertPresentException from selenium.common.exceptions import NoAlertPresentException
driver = webdriver.Firefox(executable_path=r'C:\Users\ME\Documents\geckodriver.exe') driver.maximize_window() location = "http://weblogic:048/webl" driver.get(location) button = driver.find_elements_by_link_text('Warning')
try: element = WebDriverWait(driver, 30).until( EC.presence_of_element_located((By.ID, "component/main?")) ) time.sleep(30)
except UnexpectedAlertPresentException: print "XSS - WAITING FOR THE SERVER CREDENTIALS *********" time.sleep(30)
#Creating Login user information print("Using encrypted Username **************************************************") print("Creating encrypted Loging Username*****************************************") QAUSER = r"C:\Python27\da-testing-login-python\official-selenium-login\auser.txt" with open(QAUSER, 'r') as psfile: for line in psfile: newuser = base64.b64decode(line) DM_USER = newuser
print("Using encrypted passord **************************************************") print("Creating encrypted Loging passwd*****************************************") # Creating Loging passwd
PASS = r"C:\Python27\da-testing-login-python\official-selenium-login\cpss.txt" with open(PASS , 'r') as psfile: for line in psfile: newpasswd = base64.b64decode(line)
DM_PASSWORD = newpasswd #driver.find_element_by_xpath("/html/body/nav/div/a[2]").click()
driver.find_element_by_id("LoginUsername").send_keys(DM_USER) print("Validating user passwod and sending the info *********") print("***************************************************") # passwdid = LoginPassword
driver.find_element_by_id("LoginPassword").send_keys(DM_PASSWORD) time.sleep(5) print("Validating Login in button and sending that info *************************") XPATH = "/html/body/form/div/div[3]/div/div[2]/button" BUTTON = driver.find_element_by_xpath("/html/body/form/div/div[3]/div/div[2]/button").click() time.sleep(30) pass finally: print("***************************************************") print("TASKS COMPLETED:QUITING THE SERVER *********") print("***************************************************") driver.quit()