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 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 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 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 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"
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"