class Sitesnap():
    global commonObject
    commonObject = CommonFunctions()

    url=Config.get('LoginpageObjects', 'URL')
    userName=Config.get('LoginpageObjects', 'username')
    passWord=Config.get('LoginpageObjects', 'passsword')
    usname_Value=Config.get('Datavalue', 'usname_value')
    password_Value=Config.get('Datavalue', 'pssword_value')
    home_lnk=Config.get('HomepageObjects', 'img_home_sitesnaplink')
    site_snap=Config.get('SitesnapObject','search_site_id')
    sitename=Config.get('SitesnapObject','sitename')
    site_li=Config.get('SitesnapObject','site_li_text')
    statsnap_value=Config.get('SitesnapObject','statsnap_value')
    create_value=Config.get('SitesnapObject','create_value')
    Actual_site_name=Config.get('SitesnapObject','Actual_sitename')
   
    def CustomTestFunctions(self,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:
            
            commonObject.loginToCrux(self.url,self.userName,self.passWord,self.usname_Value,self.password_Value,driver)
            # Navigate to Sitesnap page.
            print "Sitesnap Loaded "
            commonObject.gotoPage(self.home_lnk,driver);
            print "Verify search textbox present or not"
            commonObject.is_exists(By.ID,self.site_snap,driver);
            print "Enter sitename in the textbox"
            commonObject.is_ElementPresent(By.ID,self.site_snap,driver).send_keys(self.sitename)
            print "Pressing tab"
            sitetab=commonObject.is_ElementPresent(By.XPATH,self.site_li,driver)
            Expected_sitename=sitetab.text
            commonObject.pageloadtime(10,driver)    
            print "Expected site"
            print Expected_sitename
            commonObject.is_ElementPresent(By.XPATH,self.site_li,driver).click()
            commonObject.pageloadtime(10,driver)      
            Actual_sitename=commonObject.is_ElementPresent(By.TAG_NAME,self.Actual_site_name,driver).text
            commonObject.pageloadtime(10,driver)    
            print "Actual site"
            print Actual_sitename
            commonObject.pageloadtime(10,driver)
            if((Expected_sitename==Actual_sitename) and 
            (commonObject.is_exists(By.XPATH,self.statsnap_value,driver) or commonObject.is_exists(By.XPATH,self.create_value,driver))):
                return True
                commonObject.logoutFromCrux(self.logout,driver)
        except AssertionError :
            print (" Tese Case Failed ")
            raise AssertionError
            return False
class Test_Cron1_PopulateForecaseDate(unittest.TestCase):

    global objAupPreferences
    global commonObject
    objAupPreferences = PopulateforecastDate()
    commonObject = CommonFunctions()

    @classmethod
    def setUpClass(cls):
        cls.driver = commonObject.firefoxDriver()

    @pytest.mark.sanity
    @pytest.mark.Regression
    def test_Verify_cron1_PopulateForecasedate(self):

        driver = self.driver

        try:
            value = objAupPreferences.CustomTestFunctions(driver)

            if value:
                print stack()[0][3] + " Test Case Passed "

            else:
                print("Assertion Error Occurred in following test case -> " +
                      stack()[0][3])
                commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
                self.fail(
                    "Assertion Error Occurred in following test case -> " +
                    stack()[0][3])

        except NoSuchElementException as e:
            commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
            self.fail(stack()[0][3] +
                      "TestCase Failed due to Element Not Found")

        except TimeoutException as e:
            commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
            self.fail(stack()[0][3] + "TestCase Failed due to Timeout")

        except Exception as e:
            commonObject.screenhotsOnFailure(stack()[0][3], driver, Root)
            self.fail(stack()[0][3] +
                      "TestCase Failed due to an Error or Exception")

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()
Exemple #3
0
class Test_Sitesnap_Functional(unittest.TestCase):

    global objsnapshot
    global commonObject
    objsnapshot = SitesnapFunctioanl()
    commonObject = CommonFunctions()

    @classmethod
    def setUpClass(cls):
        cls.driver = commonObject.firefoxDriver()

#   @test(groups=["unit", "numbers"])

    def test_Verify_siteSnap_Functioal(self):

        driver = self.driver

        try:
            value = objsnapshot.CustomTestFunctions(driver)

            if value:
                print stack()[0][3] + " Test Case Passed "

            else:
                print("Assertion Error Occurred in following test case -> " +
                      stack()[0][3])
                commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
                self.fail(
                    "Assertion Error Occurred in following test case -> " +
                    stack()[0][3])

        except NoSuchElementException as e:
            commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
            self.fail(stack()[0][3] +
                      "TestCase Failed due to Element Not Found")

        except TimeoutException as e:
            commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
            self.fail(stack()[0][3] + "TestCase Failed due to Timeout")

        except Exception as e:
            commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
            self.fail(stack()[0][3] +
                      "TestCase Failed due to an Error or Exception")

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()
Exemple #4
0
class Test_Cron4_CruxCxRestIntegration_cron4(unittest.TestCase):

    global objPopulatedate
    global commonObject
    objPopulatedate = PerformCruxCxRestIntegration_cron4()
    commonObject = CommonFunctions()

    @classmethod
    def setUpClass(cls):
        cls.driver = commonObject.firefoxDriver()

    def test_Verify_cron4_PopulateForecasedate(self):

        driver = self.driver

        try:
            value = objPopulatedate.CustomTestFunctions(driver)

            if value:
                print stack()[0][3] + " Test Case Passed "

            else:
                print("Assertion Error Occurred in following test case -> " +
                      stack()[0][3])
                commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
                self.fail(
                    "Assertion Error Occurred in following test case -> " +
                    stack()[0][3])

        except NoSuchElementException as e:
            commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
            self.fail(stack()[0][3] +
                      "TestCase Failed due to Element Not Found")

        except TimeoutException as e:
            commonObject.screenshotsOnFailure(stack()[0][3], driver, Root)
            self.fail(stack()[0][3] + "TestCase Failed due to Timeout")

        except Exception as e:
            commonObject.screenhotsOnFailure(stack()[0][3], driver, Root)
            self.fail(stack()[0][3] +
                      "TestCase Failed due to an Error or Exception")

    @classmethod
    def tearDownClass(cls):
        cls.driver.quit()
class AupPreferences():
    global commonObject
    commonObject = CommonFunctions()

    url = Config.get('LoginpageObjects', 'URL')
    userName = Config.get('LoginpageObjects', 'username')
    passWord = Config.get('LoginpageObjects', 'passsword')
    usname_Value = Config.get('Datavalue', 'usname_value')
    password_Value = Config.get('Datavalue', 'pssword_value')
    firstSiteName = Config.get('AupPreferencesObject', 'td_preferences_id')
    siteDeleteBtn = Config.get('AupPreferencesObject', 'btn_preferences_id')
    siteConfirmDeleteBtn = Config.get('AupPreferencesObject',
                                      'btn_preferences_confirm')
    siteSearchText = Config.get('AupPreferencesObject',
                                'txt_preferences_gsearch')
    actualMessage = Config.get('AupPreferencesObject', 'lbl_prefernces_actual')
    expectedMessage = Config.get('AupPreferencesObject', 'Expected_message')
    logout = Config.get('AupPreferencesObject', 'lnk_preferences_logout')
    check_button = Config.get('AupPreferencesObject', 'Check_new_aup')
    confirm_button = Config.get('AupPreferencesObject', 'Check_new_add')
    site_count = Config.get('AupPreferencesObject', 'count_site')
    expectedMessage_addsite = Config.get('AupPreferencesObject',
                                         'Expected_site_message')
    home_lnk = Config.get('HomepageObjects', 'img_home_schedulerLink')
    aup_shd_lnk = Config.get('AupSchedulerObject',
                             'lnk_scheduler_PreferenceMenuLink')

    def CustomTestFunctions(self, 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)
            commonObject.loginToCrux(self.url, self.userName, self.passWord,
                                     self.usname_Value, self.password_Value,
                                     driver)
            #             commonObject.timeDelay(self.home_lnk,driver)

            #             element = WebDriverWait(driver, 60).until((EC.visibility_of_element_located(By.XPATH, self.home_lnk)))
            # Navigate to AUP preferences page from Home page.
            self.gotoPreferencesview(commonObject, self.home_lnk,
                                     self.aup_shd_lnk, driver)
            #driver.get("https://kalaiselvan-ramu.hmsdev.lan/sitesnap/aup_preferences")
            Actual_mesg = self.deletePreference(
                commonObject, self.firstSiteName, self.siteDeleteBtn,
                self.siteConfirmDeleteBtn, self.siteSearchText,
                self.actualMessage, self.expectedMessage, Root, driver)
            ## Logout from CRUX and kill the browser object
            assert Actual_mesg == self.expectedMessage
            # 	    print self.expectedMessage
            commonObject.logoutFromCrux(self.logout, driver)
            return True

        except AssertionError:
            print(" Tese Case Failed ")
            raise AssertionError
            return False

    def gotoPreferencesview(self, commonObject, 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
        commonObject.gotoPage(schedulerLink, driver)

        print "On Schedueler page, Clicking on AUP Preferences Link"
        # You are on AUP Scheduler main view. find Preference link and Click
        commonObject.gotoPage(preferenceLink, driver)
        driver.set_page_load_timeout(10)

    def deletePreference(self, commonObject, firstSiteName, delete,
                         confirm_del, search_txt, meassage, Expected_message,
                         root, driver):
        """Delete the table Content"""

        print "Get the first site name"

        sitename = commonObject.is_ElementPresent(By.XPATH, firstSiteName,
                                                  driver).text

        # Click on Delete button
        print "site name is :" + sitename

        print "Click on Delete button"
        delButton = commonObject.is_ElementPresent(By.XPATH, delete, driver)
        delButton.click()
        # Confirm the delete operation
        print "Confirm the delete operation"
        commonObject.is_ElementPresent(By.XPATH, confirm_del, driver).click()
        driver.set_page_load_timeout(10)
        # Searching for the deleted site
        print "searching for the deleted site"

        commonObject.is_ElementPresent(By.XPATH, search_txt,
                                       driver).send_keys(sitename)
        #         commonObject.is_ElementPresent(By.XPATH,meassage,driver).text

        Actual_message = commonObject.is_ElementPresent(
            By.XPATH, meassage, driver).text

        return Actual_message

    def addPreference(self, driver, commonObject):
        """Add the table Content"""

        try:

            #login to Crux
            commonObject.loginToCrux(self.url, self.userName, self.passWord,
                                     self.usname_Value, self.password_Value,
                                     driver)
            commonObject.timeDelay(self.home_lnk)
            # Navigate to AUP preferences page from Home page.
            self.gotoPreferencesview(commonObject, self.home_lnk,
                                     self.aup_shd_lnk, driver)
            commonObject.is_ElementPresent(By.ID, self.check_button,
                                           driver).click()
            commonObject.is_ElementPresent(By.XPATH, self.confirm_button,
                                           driver).click()
            Actual_mesg = commonObject.is_ElementPresent(
                By.ID, self.site_count, driver).text

            #             asserts.assert_equal(Actual_mesg,expectedMessage)
            assert Actual_mesg == self.expectedMessage_addsite

            #  commonObject.logoutFromCrux(self.logout,driver)
            return True
            commonObject.logoutFromCrux(self.logout, driver)

        except AssertionError:
            print(" Tese Case Failed ")
            raise AssertionError
            return False
Exemple #6
0
class PerformAupUpgradeSiteCreation_cron3():
    global commonObject
    commonObject = CommonFunctions()

    url = Config.get('LoginpageObjects', 'URL')
    userName = Config.get('LoginpageObjects', 'username')
    passWord = Config.get('LoginpageObjects', 'passsword')
    usname_Value = Config.get('Datavalue', 'usname_value')
    password_Value = Config.get('Datavalue', 'pssword_value')
    aup_shd_lnk = Config.get('PerformAupUpgradeSiteCreation', 'menu_id')
    home_lnk = Config.get('HomepageObjects', 'img_home_schedulerLink')
    check_box = Config.get('PerformAupUpgradeSiteCreation', 'check_box')
    change_button = Config.get('PerformAupUpgradeSiteCreation',
                               'change_date_button')
    site_forecast_date = Config.get('PerformAupUpgradeSiteCreation',
                                    'site_forecast_date')
    change_button_submit = Config.get('PerformAupUpgradeSiteCreation',
                                      'change_button_submit')
    home_lnk_page = Config.get('PerformAupUpgradeSiteCreation',
                               'home_lnk_page')
    Admin_lnk = Config.get('PerformAupUpgradeSiteCreation', 'Admin_lnk')
    view_lnk = Config.get('PerformAupUpgradeSiteCreation', 'view_lnk')
    cron3_lnk = Config.get('PerformAupUpgradeSiteCreation', 'cron3_lnk')
    run = Config.get('PerformAupUpgradeSiteCreation', 'run')

    def CustomTestFunctions(self, driver):
        try:

            commonObject.loginToCrux(self.url, self.userName, self.passWord,
                                     self.usname_Value, self.password_Value,
                                     driver)
            self.gotoPreferencesview(commonObject, self.home_lnk,
                                     self.aup_shd_lnk, driver)

            alert_mes = self.cronjob3_run(commonObject, driver,
                                          self.home_lnk_page, self.Admin_lnk,
                                          self.cron3_lnk, self.view_lnk,
                                          self.run)
            return True

        except AssertionError:
            print(" Tese Case Failed ")
            raise AssertionError
            return False

    def gotoPreferencesview(self, commonObject, 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
        commonObject.gotoPage(schedulerLink, driver)

        print "On Schedueler page, Clicking on AUP Preferences Link"
        # You are on AUP Scheduler main view. find Preference link and Click
        commonObject.gotoPage(preferenceLink, driver)
        driver.set_page_load_timeout(10)

    def cronjob3_run(self, commonObject, driver, home_lnk_page, Admin_lnk,
                     cron2_lnk, view_lnk, run):
        print "Returning Home page"
        commonObject.gotoPage(home_lnk_page, driver)
        commonObject.pageloadtime(10, driver)
        print "Clicking on Admin page"
        commonObject.gotoPage(Admin_lnk, driver)
        commonObject.pageloadtime(10, driver)
        print "Clicking on View page"
        commonObject.gotoPage(view_lnk, driver)
        commonObject.pageloadtime(10, driver)
        print "Clicking on Cron3 Tab"
        commonObject.gotoPage(cron2_lnk, driver)
        print "Running Cron"
        job_id = int(
            commonObject.is_ElementPresent(By.XPATH, "//tr[1]/td[1]",
                                           driver).text)
        commonObject.gotoPage(run, driver)
        commonObject.pageloadtime(10, driver)
        alert_msg = commonObject.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 = commonObject.is_ElementPresent(By.XPATH, "//tr[1]/td[2]",
                                                   driver).text

        print "After CronRun looks for the message"
        afterrun_message_txt = commonObject.is_ElementPresent(
            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"
class Populatedate_cron2():
    global commonObject
    commonObject = CommonFunctions()

    url=Config.get('LoginpageObjects', 'URL')
    userName=Config.get('LoginpageObjects', 'username')
    passWord=Config.get('LoginpageObjects', 'passsword')
    usname_Value=Config.get('Datavalue', 'usname_value')
    password_Value=Config.get('Datavalue', 'pssword_value')
    home_lnk=Config.get('HomepageObjects', 'img_home_schedulerLink')
    product_release_info=Config.get('ProductreleaseinfoObject', 'menu_product_release_id')
    product_release_Addnew=Config.get('ProductreleaseinfoObject', 'new_product_release_info_id')
    dropdown=Config.get('ProductreleaseinfoObject','dropdown')
    prod_release_date=Config.get('ProductreleaseinfoObject','prod_release_date')
    patch_date=Config.get('ProductreleaseinfoObject','patch_date')
    addbutton=Config.get('ProductreleaseinfoObject','Addbutton')
    siteSearchText = Config.get('ProductreleaseinfoObject', 'txt_preferences_gsearch')
    home_lnk_page=Config.get('ProductreleaseinfoObject', 'home_lnk_page')
    Admin_lnk=Config.get('ProductreleaseinfoObject', 'Admin_lnk')
    view_lnk=Config.get('ProductreleaseinfoObject', 'view_lnk')
    cron2_lnk=Config.get('ProductreleaseinfoObject', 'cron2_lnk')
    run=Config.get('ProductreleaseinfoObject', 'run')
  
    def CustomTestFunctions(self,driver):
        """To Run the Cron2 Job"""
      
        try:
            commonObject.loginToCrux(self.url,self.userName,self.passWord,self.usname_Value,self.password_Value,driver)
#             self.gotoPreferencesview(commonObject,self.home_lnk,self.product_release_info,driver)
            print "Clicking scheduler menu in the home page "
            commonObject.gotoPage(self.home_lnk,driver)
            commonObject.pageloadtime(10,driver)
            print "Clicking Product Release Information menu Scheduler Page "
            commonObject.gotoPage(self.product_release_info,driver)
            print "Deleting entire Product release Details"
            bool_Delete=commonObject.delete_table(driver)
            print"If the Forecast date exists Delete "
            if(bool_Delete):
                form_string=self.Add_details(driver, self.product_release_Addnew)
                bool_value=commonObject.select_by_text(driver,self.dropdown,form_string)
                commonObject.pageloadtime(10, driver)
                if(bool_value):
                    actual_info=self.prodcut_release_info(driver,commonObject,self.prod_release_date,self.patch_date,self.addbutton,self.siteSearchText,form_string)
                    alert_mes=self.cronjob2_run(commonObject,driver,self.home_lnk_page,self.Admin_lnk,self.cron2_lnk,self.view_lnk,self.run)
                    assert alert_mes=="Finished"
                    return True
             
            else:
                print"If Forecast date Not exists Create New one" 
                form_string=self.Add_details(driver, self.product_release_Addnew)
                commonObject.pageloadtime(10, driver)
                bool_value=commonObject.select_by_text(driver,self.dropdown,form_string)
                self.prodcut_release_info(driver,commonObject,self.prod_release_date,self.patch_date,self.addbutton,self.siteSearchText,form_string)
                alert_mes=self.cronjob2_run(commonObject,driver,self.home_lnk_page,self.Admin_lnk,self.cron2_lnk,self.view_lnk,self.run)
                assert alert_mes=="Finished"
                return True
            
        except AssertionError :
            print (" Tese Case Failed ")
            raise AssertionError
            return False

        
    def Add_details(self,driver,product_addnew):
        """To Add details in the Site"""
        commonObject.gotoPage(product_addnew,driver)
        commonObject.pageloadtime(10,driver)
        print "Current month"      
        currentmonth=commonObject.timestampmonth()
        print currentmonth  
        print "Current Year"    
        currentyear=commonObject.timestampyear()
          
        print "Release date"
        release=self.datecalculation(driver,commonObject,currentmonth)
        print release  
        print"Form String"
        form_string=self.formstring(driver,release,currentyear)
        print form_string
        return form_string

    
    def datecalculation(self,driver,commonObject,curmonth):
        """To Caculate the date"""
        first_term_release=['February','March','April']
        second_term_release=['May','June','July']
        third_term_release=['August','September','October']
        fourth_term_release=['November','December','January']
        
        if curmonth in first_term_release:
            return "February"
        elif curmonth in second_term_release:
            return "May"
        elif curmonth in third_term_release:
            return "August"
        else:
            return "November" 
        
    def cronjob2_run(self,commonObject,driver,home_lnk_page,Admin_lnk,cron2_lnk,view_lnk,run):
        
        print "Returning Home page"
        commonObject.gotoPage(home_lnk_page,driver)
        commonObject.pageloadtime(10,driver)
        print "Clicking on Admin page"
        commonObject.gotoPage(Admin_lnk,driver)
        commonObject.pageloadtime(10,driver)
        print "Clicking on View page"
        commonObject.gotoPage(view_lnk,driver)
        commonObject.pageloadtime(10,driver)
        print "Clicking on Cron2 Tab"
        commonObject.gotoPage(cron2_lnk,driver)   
        time.sleep(10)

        print "Running Cron"
        job_id=int(commonObject.is_ElementPresent(By.XPATH,"//tr[1]/td[1]",driver).text)
        commonObject.gotoPage(run,driver)
        time.sleep(10)
        alert_msg=commonObject.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=commonObject.is_ElementPresent(By.XPATH,"//tr[1]/td[2]",driver).text
        print cron2_txt
        print "After CronRun looks for the message"
        afterrun_message_txt=commonObject.is_ElementPresent(By.XPATH,"//tr[1]/td[5]",driver).text
        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 prodcut_release_info(self,driver,commonObject,prod_release_date,patch_date,addbutton,siteSearchText,form_string):
        print "Select Current Date"
        cdate=commonObject.currentdate()
        time.sleep(10)
        print cdate
        commonObject.is_ElementPresent(By.XPATH,prod_release_date, driver).send_keys(cdate)
        commonObject.pageloadtime(10, driver)
        commonObject.is_ElementPresent(By.XPATH,prod_release_date, driver).send_keys(Keys.ENTER)
        time.sleep(10)
        print "Select Next Date"
        patchdate=commonObject.nextdate()
        time.sleep(10)
        print patchdate

        commonObject.pageloadtime(10, driver)
        commonObject.is_ElementPresent(By.XPATH,patch_date, driver).send_keys(patchdate)
#         commonObject.is_ElementPresent(By.XPATH,patch_date, driver).send_keys(Keys.ENTER)
        commonObject.pageloadtime(10, driver)
        print "Clicking on the Add Date"
        commonObject.is_ElementPresent(By.XPATH,addbutton,driver).click()
        print "searching for the Product release Version"
        commonObject.is_ElementPresent(By.XPATH,siteSearchText,driver).send_keys(form_string)
        commonObject.is_ElementPresent(By.XPATH,siteSearchText, driver).send_keys(Keys.ENTER)
        text_td="//td[text()='"+form_string+"']"
        Actual_prod=commonObject.is_ElementPresent(By.XPATH,text_td,driver).text
        
        return Actual_prod
        
    def formstring(self,driver,release,year):
        str="Oracle Service Cloud "+release+" "+year
        return str
Exemple #8
0
class ProductReleaseInformation():
    global commonObject
    commonObject = CommonFunctions()

    url = Config.get('LoginpageObjects', 'URL')
    userName = Config.get('LoginpageObjects', 'username')
    passWord = Config.get('LoginpageObjects', 'passsword')
    usname_Value = Config.get('Datavalue', 'usname_value')
    password_Value = Config.get('Datavalue', 'pssword_value')
    generateForecasteDate_btn = Config.get('ProductReleaseInformationObject',
                                           'generateForecasteDate_btn')
    print generateForecasteDate_btn
    runbatch_text = Config.get('ProductReleaseInformationObject',
                               'runbatch_text')
    proceed_btn = Config.get('ProductReleaseInformationObject', 'proceed_btn')
    ok_btn = Config.get('ProductReleaseInformationObject', 'ok_btn')
    aup_shd_lnk_proce = Config.get('AupSchedulerObject',
                                   'lnk_scheduler_ProductMenuLink')
    expectedMessage = "Generated Forecast Dates For 17.8"
    home_lnk = Config.get('HomepageObjects', 'img_home_schedulerLink')

    def CustomTestFunctions(self, 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)
            commonObject.loginToCrux(self.url, self.userName, self.passWord,
                                     self.usname_Value, self.password_Value,
                                     driver)

            # Navigate to AUP preferences page from Home page.
            self.gotoPreferencesview(commonObject, self.home_lnk,
                                     self.aup_shd_lnk_proce, driver)

            Actual_mesg = self.generateForecasteDate(
                commonObject, self.generateForecasteDate_btn,
                self.runbatch_text, self.proceed_btn, self.ok_btn, Root,
                driver)

            print Actual_mesg
            ## Logout from CRUX and kill the browser object
            assert Actual_mesg == self.expectedMessage
            return True
#             commonObject.logoutFromCrux(self.logout,driver)
#             return True

        except AssertionError:
            print(" Tese Case Failed ")
            raise AssertionError
            return False

    def gotoPreferencesview(self, commonObject, schedulerLink,
                            ProductReleaseInformationObject, 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
        commonObject.gotoPage(schedulerLink, driver)
        time.sleep(20)
        print "On ProductReleaseInformation page, Clicking on ProductReleaseInformation Link"
        # You are on AUP Scheduler main view. find Preference link and Click
        commonObject.gotoPage(ProductReleaseInformationObject, driver)
        driver.set_page_load_timeout(10)

    def generateForecasteDate(self, commonObject, generateForecasteDate_btn,
                              runbatch_text, proceed_btn, ok_btn, Root,
                              driver):

        try:

            commonObject.is_ElementPresent(By.XPATH, generateForecasteDate_btn,
                                           driver).click()
            time.sleep(10)
            commonObject.is_ElementPresent(By.XPATH, proceed_btn,
                                           driver).click()
            time.sleep(10)
            Actual_message = commonObject.is_ElementPresent(
                By.XPATH, runbatch_text, driver).text
            time.sleep(10)
            commonObject.is_ElementPresent(By.XPATH, ok_btn, driver).click()
            return Actual_message
        except AssertionError:
            print(" Tese Case Failed ")
            raise AssertionError
            return False
Exemple #9
0
class PopulateforecastDate():
    global commonObject
    commonObject = CommonFunctions()

    url = Config.get('LoginpageObjects', 'URL')
    userName = Config.get('LoginpageObjects', 'username')
    passWord = Config.get('LoginpageObjects', 'passsword')
    usname_Value = Config.get('Datavalue', 'usname_value')
    password_Value = Config.get('Datavalue', 'pssword_value')
    firstSiteName = Config.get('AupPreferencesObject', 'td_preferences_id')
    siteDeleteBtn = Config.get('AupPreferencesObject', 'btn_preferences_id')
    siteConfirmDeleteBtn = Config.get('AupPreferencesObject',
                                      'btn_preferences_confirm')
    siteSearchText = Config.get('AupPreferencesObject',
                                'txt_preferences_gsearch')
    actualMessage = Config.get('AupPreferencesObject', 'lbl_prefernces_actual')
    expectedMessage = Config.get('AupPreferencesObject', 'Expected_message')
    norecordMessage = Config.get('AupPreferencesObject', 'Norecord_messge')
    logout = Config.get('AupPreferencesObject', 'lnk_preferences_logout')
    check_button = Config.get('AupPreferencesObject', 'Check_new_aup')
    confirm_button = Config.get('AupPreferencesObject', 'Check_new_add')
    site_count = Config.get('AupPreferencesObject', 'count_site')
    expectedMessage_addsite = Config.get('AupPreferencesObject',
                                         'Expected_site_message')
    home_lnk = Config.get('HomepageObjects', 'img_home_schedulerLink')
    aup_shd_lnk = Config.get('AupSchedulerObject',
                             'lnk_scheduler_PreferenceMenuLink')

    def CustomTestFunctions(self, 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)
            commonObject.loginToCrux(self.url, self.userName, self.passWord,
                                     self.usname_Value, self.password_Value,
                                     driver)
            # Navigate to AUP preferences page from Home page.
            self.gotoPreferencesview(commonObject, self.home_lnk,
                                     self.aup_shd_lnk, driver)
            #driver.get("https://kalaiselvan-ramu.hmsdev.lan/sitesnap/aup_preferences")
            message = commonObject.is_ElementPresent(By.XPATH,
                                                     self.norecordMessage,
                                                     driver).text
            time.sleep(10)
            count = self.message_split(commonObject, driver)

            if (message == "No data available in table"):
                self.populatesite(commonObject, driver)
                return True
#             count =self.populatesite(commonObject,self.actualMessage,self.norecordMessage,driver)
            elif (count > 0):

                commonObject.is_ElementPresent(
                    By.XPATH, "//table/tbody/tr[1]/td[16]/button[2]",
                    driver).click()
                driver.set_page_load_timeout(10)
                commonObject.is_ElementPresent(By.XPATH,
                                               "//div[11]/div/button[1]",
                                               driver).click()
                driver.set_page_load_timeout(10)
                self.deletePreference(commonObject, self.firstSiteName,
                                      self.siteDeleteBtn,
                                      self.siteConfirmDeleteBtn, driver)
                time.sleep(10)
                less_count = self.message_split(commonObject, driver)
                print less_count
                time.sleep(10)
                self.populatesite(commonObject, driver)
                actual_count = self.message_split(commonObject, driver)
                print actual_count
                if (actual_count > less_count):
                    return True

#

        except AssertionError:
            print(" Tese Case Failed ")
            raise AssertionError
            return False

    def deletePreference(self, commonObject, firstSiteName, delete,
                         confirm_del, driver):
        """Delete the table Content"""

        print "Click on Delete button"
        delButton = commonObject.is_ElementPresent(By.XPATH, delete, driver)
        delButton.click()
        # Confirm the delete operation
        print "Confirm the delete operation"
        commonObject.is_ElementPresent(By.XPATH, confirm_del, driver).click()
        driver.set_page_load_timeout(10)
        # Searching for the deleted site

    def gotoPreferencesview(self, commonObject, 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

        commonObject.gotoPage(schedulerLink, driver)

        print "On Schedueler page, Clicking on AUP Preferences Link"
        # You are on AUP Scheduler main view. find Preference link and Click
        commonObject.gotoPage(preferenceLink, driver)
        driver.set_page_load_timeout(10)

    def populatesite(self, commonObject, driver):
        """Populating the site"""

        commonObject.is_ElementPresent(By.XPATH,
                                       "//*[@id='new_aup_preferences_info']",
                                       driver).click()
        commonObject.is_ElementPresent(By.XPATH, "//span[text()='Add']",
                                       driver).click()

    def message_split(self, commonObject, driver):
        """Spliting the Messages"""
        message_detail = commonObject.is_ElementPresent(
            By.XPATH, "//*[@id='aup_pref_info']", driver).text

        data = message_detail.split()  #split string into a list

        count = int(data[5])
        return count
class SitesnapFunctioanl():
    global commonObject
    commonObject = CommonFunctions()

    url=Config.get('LoginpageObjects', 'URL')
    userName=Config.get('LoginpageObjects', 'username')
    passWord=Config.get('LoginpageObjects', 'passsword')
    usname_Value=Config.get('Datavalue', 'usname_value')
    password_Value=Config.get('Datavalue', 'pssword_value')
    home_lnk=Config.get('HomepageObjects', 'img_home_sitesnaplink')
    site_snap=Config.get('SitesnapObject','search_site_id')
    sitename=Config.get('SitesnapObject','sitename')
    site_li=Config.get('SitesnapObject','site_li_text')
    statsnap_value=Config.get('SitesnapObject','statsnap_value')
    create_value=Config.get('SitesnapObject','create_value')
    Actual_site_name=Config.get('SitesnapObject','Actual_sitename')
    Sitesnap_content=Config.get('SitesnapObject','sitesnap_content')
    qualified_text=Config.get('SitesnapObject','qualified')
    enroll_text=Config.get('SitesnapObject','enroll')
   
    def CustomTestFunctions(self,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:
            
            commonObject.loginToCrux(self.url,self.userName,self.passWord,self.usname_Value,self.password_Value,driver)
            # Navigate to Sitesnap page.
            print "Sitesnap Loaded "
            commonObject.gotoPage(self.home_lnk,driver);
            print "Verify search textbox present or not"
            commonObject.is_exists(By.ID,self.site_snap,driver);
            print "Enter sitename in the textbox"
            commonObject.is_ElementPresent(By.ID,self.site_snap,driver).send_keys(self.sitename)
            print "Pressing tab"
            sitetab=commonObject.is_ElementPresent(By.XPATH,self.site_li,driver)
            print "Expected site"
            Expected_sitename=sitetab.text
            print "Waiting"
            commonObject.pageloadtime(10,driver)    
            print "Clicking on the site"
            commonObject.is_ElementPresent(By.XPATH,self.site_li,driver).click()
            print "Waiting"
            commonObject.pageloadtime(10,driver)
            commonObject.is_ElementPresent(By.XPATH,self.statsnap_value,driver).click() 
            print "Completing the process"
            time.sleep(20)
            print "Extracting Datas"
            qualification_text=commonObject.is_ElementPresent(By.XPATH,self.qualified_text,driver).text
            print "Spliting the date String "
            Actual_data=commonObject.string_split(self.Sitesnap_content,"\n",driver);
            print "Getting Actual site"
            Actual_sitename=commonObject.is_ElementPresent(By.TAG_NAME,self.Actual_site_name,driver).text
            commonObject.pageloadtime(10,driver)    
            print "Actual site"
            print Actual_sitename
            print "Getting Enrollment Status"
            commonObject.pageloadtime(10,driver)
            enrollment_text=commonObject.is_ElementPresent(By.XPATH,self.enroll_text,driver).text
            commonObject.pageloadtime(10,driver)
            print "Getting current date and time"
            date_time=commonObject.timestamp()
            """Comparing all the extracted data Against to the site"""
            
            if((Expected_sitename==Actual_sitename) and 
            (qualification_text=="NOT QUALIFIED" or qualification_text=="QUALIFIED" ) and 
            (enrollment_text=="normal" or enrollment_text=="automatic") and (date_time in Actual_data[3])):
                return True
                commonObject.logoutFromCrux(self.logout,driver)           
            
            
        except AssertionError :
            print (" Tese Case Failed ")
            raise AssertionError
            return False