def customTestFunctions(driver): try: common.loginToCrux(userName, passWord, usname_Value, password_Value, driver) except AssertionError: print(" Tese Case Failed ") raise AssertionError return False
def gotoPreferencesview(common, schedulerLink, preferenceLink, driver): """This function opens the AUP Preferences view""" print "On Home page, Clicking on Scheduler Link" # You are now on home page. Search scheduler link and click common.gotoPage(schedulerLink, driver) print "On Schedueler page, Clicking on AUP Preferences Link" # You are on AUP Scheduler main view. find Preference link and Click common.gotoPage(preferenceLink, driver) driver.set_page_load_timeout(10)
def deletePreference(common, firstSiteName, delete, confirm_del, driver): """Delete the table Content""" print "Click on Delete button" delButton = common.find_element(By.XPATH, delete, driver) delButton.click() # Confirm the delete operation print "Confirm the delete operation" common.find_element(By.XPATH, confirm_del, driver).click() driver.set_page_load_timeout(10)
def test_cron3_performAupUpgradeSiteCreation(driver): value = custom.customTestFunctions(driver) if value: print stack()[0][3] + " Test Case Passed " else: print("Assertion Error Occurred in following test case -> " + stack()[0][3]) common.screenshotsOnFailure(stack()[0][3], driver, Root)
def test_Cron4_CruxCxRestIntegration_cron4(driver): value = custom.CustomTestFunctions(driver) if value: print stack()[0][3] + " Test Case Passed " else: print("Assertion Error Occurred in following test case -> " + stack()[0][3]) common.screenshotsOnFailure(stack()[0][3], driver, Root)
def test_cron2_populateForecaseDate(driver): value = custom.customTestFunctions(driver) if value: print stack()[0][3] + " Test Case Passed " else: print("Assertion Error Occurred in following test case -> " + stack()[0][3]) common.screenshotsOnFailure(stack()[0][3], driver, Root)
def customTestFunctions(driver): try: common.loginToCrux(userName, passWord, usname_Value, password_Value, driver) # gotoPreferencesview(common,home_lnk,aup_shd_lnk,driver) alert_mes = cronjob4_run(common, driver, home_lnk_page, Admin_lnk, cron4_lnk, view_lnk, run) return True except AssertionError: print(" Tese Case Failed ") raise AssertionError return False
def test_Cron1_AupPreferences(driver): value = custom.customTestFunctions(driver) if value: print stack()[0][3] + " Test Case Passed " else: print("Assertion Error Occurred in following test case -> " + stack()[0][3]) common.screenshotsOnFailure(stack()[0][3], driver, Root) # fail("Assertion Error Occurred in following test case -> "+stack()[0][3])
def message_split(common, driver): """Spliting the Messages""" message_detail = common.find_element(By.XPATH, "//*[@id='aup_pref_info']", driver).text data = message_detail.split() #split string into a list count = int(data[5]) return count
def customTestFunctions(driver): # print func_name """This function will create the object for AUP preferences view controller and triggers the required UI test cases via the class methods""" try: # print os.path.abspath(os.curdir) common.loginToCrux(userName, passWord, usname_Value, password_Value, driver) # Navigate to AUP preferences page from Home page. gotoPreferencesview(common, home_lnk, aup_shd_lnk, driver) message = common.find_element(By.XPATH, norecordMessage, driver).text time.sleep(10) count = message_split(common, driver) if (message == "No data available in table"): populatesite(common, driver) return True # count =self.populatesite(common,self.actualMessage,self.norecordMessage,driver) elif (count > 0): # //table/tbody/tr[1]/td[16]/button[2] common.find_element(By.XPATH, "//table/tbody/tr[1]/td[16]/button[2]", driver).click() driver.set_page_load_timeout(10) common.find_element(By.XPATH, "//div[11]/div/button[1]", driver).click() driver.set_page_load_timeout(10) deletePreference(common, firstSiteName, siteDeleteBtn, siteConfirmDeleteBtn, driver) time.sleep(10) less_count = message_split(common, driver) print less_count time.sleep(10) populatesite(common, driver) actual_count = message_split(common, driver) print actual_count if (actual_count > less_count): return True except AssertionError: print(" Tese Case Failed ") raise AssertionError return False
def add_details(driver, product_addnew): """To Add details in the Site""" common.gotoPage(product_addnew, driver) common.pageLoadTime(10, driver) print "Current month" currentmonth = common.timestampMonth() print currentmonth print "Current Year" currentyear = common.timestampYear() print "Release date" release = datecalculation(driver, common, currentmonth) print release print "Form String" form_string = formstring(driver, release, currentyear) print form_string return form_string
def cronjob4_run(common, driver, home_lnk_page, Admin_lnk, cron4_lnk, view_lnk, run): """This Function helps to run from the Cron tab 4""" print "Clicking on Admin page" common.gotoPage(Admin_lnk, driver) common.pageLoadTime(10, driver) print "Clicking on View page" common.gotoPage(view_lnk, driver) common.pageLoadTime(10, driver) print "Clicking on Cron4 Tab" common.gotoPage(cron4_lnk, driver) print "Running Cron" job_id = int(common.find_element(By.XPATH, "//tr[1]/td[1]", driver).text) common.gotoPage(run, driver) common.pageLoadTime(10, driver) alert_msg = common.alert_present(driver) print "New JoB Id has been created" job_id_new = job_id + 1 print job_id print "After Running cron looks for the text" cron4_txt = common.find_element(By.XPATH, "//tr[1]/td[2]", driver).text print job_id_new print "After CronRun looks for the message" afterrun_message_txt = common.find_element(By.XPATH, "//tr[1]/td[5]", driver).text print afterrun_message_txt if (job_id != job_id_new and cron4_txt == "Crux CX Rest Integration ('Job 4')" and afterrun_message_txt == "There were no forecast dates to be synched to CX"): return "Finished" else: return "Failed"
def populatesite(common, driver): """Populating the site""" common.find_element(By.XPATH, "//*[@id='new_aup_preferences_info']", driver).click() common.find_element(By.XPATH, "//span[text()='Add']", driver).click()
def cronjob3_run(common, driver, home_lnk_page, Admin_lnk, cron2_lnk, view_lnk, run): """This Function helps to run from the Cron tab 3""" print "Returning Home page" common.gotoPage(home_lnk_page, driver) common.pageLoadTime(10, driver) print "Clicking on Admin page" common.gotoPage(Admin_lnk, driver) common.pageLoadTime(10, driver) print "Clicking on View page" common.gotoPage(view_lnk, driver) common.pageLoadTime(10, driver) print "Clicking on Cron3 Tab" common.gotoPage(cron2_lnk, driver) print "Running Cron" job_id = int(common.find_element(By.XPATH, "//tr[1]/td[1]", driver).text) common.gotoPage(run, driver) common.pageLoadTime(10, driver) alert_msg = common.alert_present(driver) print "New JoB Id has been created" job_id_new = job_id + 1 print "After Running cron looks for the text" cron3_txt = common.find_element(By.XPATH, "//tr[1]/td[2]", driver).text print "After CronRun looks for the message" afterrun_message_txt = common.find_element(By.XPATH, "//tr[1]/td[5]", driver).text if (job_id != job_id_new and cron3_txt == "AUP Upgrade Site Creation ('Job 3')" and "Total Sites forecasted on" in afterrun_message_txt): return "Finished" else: return "Failed"
def customTestFunctions(driver): """To Run the Cron2 Job""" try: common.loginToCrux(userName, passWord, usname_Value, password_Value, driver) # gotoPreferencesview(common,home_lnk,product_release_info,driver) print "Clicking scheduler menu in the home page " common.gotoPage(home_lnk, driver) common.pageLoadTime(10, driver) print "Clicking Product Release Information menu Scheduler Page " common.gotoPage(product_release_info, driver) print "Deleting entire Product release Details" bool_Delete = common.delete_table(driver) print "If the Forecast date exists Delete" if (bool_Delete): form_string = add_details(driver, product_release_Addnew) bool_value = common.select_by_text(driver, dropdown, form_string) common.pageLoadTime(10, driver) if (bool_value): actual_info = prodcut_release_info(driver, common, prod_release_date, patch_date, addbutton, siteSearchText, form_string) alert_mes = cronjob2_run(common, driver, home_lnk_page, Admin_lnk, cron2_lnk, view_lnk, run) assert alert_mes == "Finished" return True else: print "If Forecast date Not exists Create New one" form_string = add_details(driver, product_release_Addnew) common.pageLoadTime(10, driver) bool_value = common.select_by_text(driver, dropdown, form_string) prodcut_release_info(driver, common, prod_release_date, patch_date, addbutton, siteSearchText, form_string) alert_mes = cronjob2_run(common, driver, home_lnk_page, Admin_lnk, cron2_lnk, view_lnk, run) assert alert_mes == "Finished" return True except NoSuchElementException: print(" Tese Case Failed ") raise NoSuchElementException return False except AssertionError: print(" Tese Case Failed ") raise AssertionError return False
def prodcut_release_info(driver, common, prod_release_date, patch_date, addbutton, siteSearchText, form_string): print "Select Current Date" cdate = common.currentdate() time.sleep(10) print cdate common.find_element(By.XPATH, prod_release_date, driver).send_keys(cdate) common.pageLoadTime(10, driver) common.find_element(By.XPATH, prod_release_date, driver).send_keys(Keys.ENTER) time.sleep(10) print "Select Next Date" patchdate = common.nextdate() time.sleep(10) print patchdate # patch_xpath="//a[text()='"+patch+"']" # print patch_xpath common.pageLoadTime(10, driver) common.find_element(By.XPATH, patch_date, driver).send_keys(patchdate) # common.find_element(By.XPATH,patch_date, driver).send_keys(Keys.ENTER) common.pageLoadTime(10, driver) print "Clicking on the Add Date" common.find_element(By.XPATH, addbutton, driver).click() print "searching for the Product release Version" common.find_element(By.XPATH, siteSearchText, driver).send_keys(form_string) common.find_element(By.XPATH, siteSearchText, driver).send_keys(Keys.ENTER) text_td = "//td[text()='" + form_string + "']" Actual_prod = common.find_element(By.XPATH, text_td, driver).text return Actual_prod
def cronjob2_run(common, driver, home_lnk_page, Admin_lnk, cron2_lnk, view_lnk, run): print "Returning Home page" common.gotoPage(home_lnk_page, driver) common.pageLoadTime(10, driver) print "Clicking on Admin page" common.gotoPage(Admin_lnk, driver) common.pageLoadTime(10, driver) print "Clicking on View page" common.gotoPage(view_lnk, driver) common.pageLoadTime(10, driver) print "Clicking on Cron2 Tab" common.gotoPage(cron2_lnk, driver) time.sleep(10) print "Running Cron" job_id = int(common.find_element(By.XPATH, "//tr[1]/td[1]", driver).text) common.gotoPage(run, driver) time.sleep(10) alert_msg = common.alert_present(driver) time.sleep(10) print "JoB Id" job_id_new = job_id + 1 time.sleep(10) print job_id_new print "After Running cron looks for the text" time.sleep(10) cron2_txt = common.find_element(By.XPATH, "//tr[1]/td[2]", driver).text print cron2_txt print "After CronRun looks for the message" afterrun_message_txt = common.find_element(By.XPATH, "//tr[1]/td[5]", driver).text # print afterrun_message_txt # print cron2_txt time.sleep(10) if (job_id != job_id_new and cron2_txt == "AUP Forecast Date Generation('Job 2')" and "Forecast Date generated for sites:" in afterrun_message_txt): return "Finished" else: return "Failed"