top of page

START INDEX SELENIUM PYTHON AUTOMATION


#########################################

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 from selenium.common.exceptions import NoSuchElementException from selenium.webdriver import ActionChains import unittest, time, re from selenium.webdriver.common.keys import Keys from selenium.webdriver.common.keys import Keys from selenium.common.exceptions import TimeoutException from selenium.webdriver.support.select import Select

driver = webdriver.Firefox(executable_path=r'C:\Users\fredr05\Documents\webdrivers\geckodriver.exe') driver.maximize_window() location = "http://InbMEEEME:1204877/dat"

location2 ="http://meeedat" actions = ActionChains(driver)

try: driver.get(location2) 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 " print("**********************************************") time.sleep(30) QAUSER = r"C:\Python27\da-testing-login-python\official-selenium-login\bdgcqauser.txt" with open(QAUSER, 'r') as psfile: for line in psfile: newuser = base64.b64decode(line) QAUSERLOGIN = newuser DM_USER = QAUSERLOGIN driver.find_element_by_id("LoginUsername").send_keys(DM_USER) CPASS = r"C:\Python27\da-testing-login-python\official-selenium-login\bdgcpss.txt" with open(CPASS, 'r') as psfile: for line in psfile: newpasswd = base64.b64decode(line) QAPASSWORD = newpasswd DM_PASSWORD = QAPASSWORD print("Using encrypted passord **************************************************") print("Creating encrypted Loging passwd*****************************************") driver.find_element_by_id("LoginPassword").send_keys(DM_PASSWORD) time.sleep(5) print("Validating Login in button and sending that info ") print("**********************************************") 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) wait = WebDriverWait(driver, 30) print("Switching to frame **********") iframe = WebDriverWait(driver, 20).until(lambda driver : driver.find_element_by_tag_name('frame')) driver.switch_to.frame(iframe) time.sleep(30)

print("Switching to default content ") driver.switch_to.default_content() print("Handling frame sctions*& *Switching to { MainEx_view_0 Frame & Classic_browser_0 ") print("**********************************") driver.switch_to.frame(driver.find_element_by_id("MainEx_view_0")) driver.switch_to.frame(driver.find_element_by_id("Classic_browser_0")) print("Finding BrowserTree_0 Tree & Finding Indexing Management") print("**********************************") IndexMngmnt = driver.find_element_by_link_text("Indexing Management") if IndexMngmnt: IndexMngmnt.tag_name IndexMngmnt.is_enabled IndexMngmnt.is_selected CLICK = IndexMngmnt.click() time.sleep(4) print("Index management accessed Successfully") print("************************ **********") time.sleep(5) S = "*****************************************************" print("Handling Indexing Agent and Servers status section ") print(S) print("Switching to the { default frame, MainEx_view_0, Classic_workarea Frame & to Form_content_0 in this order}") driver.switch_to.default_content() driver.switch_to.frame(driver.find_element_by_id("MainEx_view_0")) time.sleep(2) driver.switch_to.frame(driver.find_element_by_id("Classic_workarea_0")) time.sleep(2) driver.switch_to.frame(driver.find_element_by_id("Form_content_0")) time.sleep(2) print(S) print("All frames processed Successfully") print(S) print("Checking index process Status") IndagntServer = driver.find_element_by_xpath("/html/body/form/div/table/tbody/tr[4]/td[2]/a") if IndagntServer: IndagntServer.is_enabled IndagntServer.is_selected CLICK = IndagntServer.click() print(S) print("Successfully Openned index Status Window") time.sleep(2) print("Dsiaplaying Server Index status") print(S) STatus = driver.find_element_by_xpath('/html/body/form/div/div[4]/table/tbody/tr[3]/td[8]') if STatus: print("INdex status located checking the current state *************") if 'running' in STatus.text.lower(): print("Index is Runing successfully in this machine") print("Quiting *** validation completed Successfully") print("Thank you~~~~~~~~~~~~~~~~~~~~~~~~~~Bye") time.sleep(30) driver.quit() else: print("Sorry index Process is Down &: Needs Immediate restart") print("*********************************************************") try: indline = driver.find_element_by_css_selector("#IndexAgentServerList_datagrid_0_2") actions = ActionChains(driver) actions.context_click(indline).perform() print("Right click Successful ***************") print("Starting index Agent ****************") driver.find_element_by_xpath("//span[@class='menu']/div[contains(.,'Start Agent')]").click() time.sleep(2) print("Going to Starting index agent frame for confirmation") print("********************************************************") try: driver.switch_to.default_content() driver.switch_to.frame(driver.find_element_by_id("MainEx_view_0")) driver.switch_to.frame(driver.find_element_by_id("Classic_workarea_0")) driver.switch_to.frame(driver.find_element_by_id("Form_content_0")) driver.switch_to.frame(driver.find_element_by_xpath('/html/frameset/frame[1]')) driver.find_element_by_css_selector("button.buttonLink:nth-child(1)").text OKLINK = driver.find_element_by_css_selector("button.buttonLink:nth-child(1)") if OKLINK: driver.find_element_by_css_selector("button.buttonLink:nth-child(1)").click() time.sleep(2) print("Index Agent Started Successfully") print("***************************************************") print("END~~~~~~~~~~~~~~~~~~~~~~~~~~~~END") time.sleep(30) except Exception as ss: print('Not able to swith to Stop index Frame: msg {} '.format(ss)) except NoSuchElementException as err: print("Sorry element specified missing!! {} :".format(err)) except TimeoutException as ex: print (" Timeout waiting for window swith to index popup: error msg = {}::".format(ex)) print("*******************************************************") except NoSuchElementException as bb: print("Element Specified (index) Missing : msg {} ".format(bb)) except TimeoutException as tmo: print (" Timeout waiting for action chains performance: error msg = {}::".format(tmo)) except Exception as ms: print('Not able to click the element: msg {} '.format(ms)) finally: print("Congratulations !!! ***Index Agent Successfully Started") print("************************************************") print("END~~~~~~~~~~~~~~~~~~~~~~~~~END") time.sleep(15) driver.quit() else: print("Sorry unable to locate index status element ...{}".format(STatus)) else: print("Sorry Unable to locate index server specified .. {}".format(IndagntServer)) else: print("Sorry unable to locate index mgmnt specified ...{}".format(IndexMngmnt))

bottom of page