Ejemplo n.º 1
0
def TC_003_FileUpload():
    try:
        globVal.testCaseName = 'TC_003_FileUpload'
        globVal.testType = 'Regression'

        #Creating object to global function
        GF_Obj = GlobalFunction()

        # Step 1
        # ==============================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Open the browser and Navigate to ' + globVal.testURL
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ==============================================================
        GF_Obj.launchApplication()
        GF_Obj.verifyWebObjDisplayed('SignUp_page', 'Passed', 'Failed',
                                     'StepName', 'ExitTest', 'WaitTime')

        # Step 2
        # ==============================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Login to the application'
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ==============================================================
        GF_Obj.clickOnWebObj('SignUp_Login_Link', 'LoginPage', 'Passed',
                             'Failed', 'Click on Login link in SignUp page',
                             'ExitTest', 'WaitTime')
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_Credentials_SheetName, 'TestingWorld',
            'UserName', 'Passed', 'Failed', 'StepName', 'ExitTest')
        GF_Obj.setDataToWebObj('Login_UserID_TextBox', testData, 'Passed',
                               'Failed', 'Enter value into user id textbox',
                               'ExitTest', 'WaitTime')
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_Credentials_SheetName, 'TestingWorld',
            'Password', 'Passed', 'Failed', 'StepName', 'ExitTest')
        GF_Obj.setDataToWebObj('Login_Password_TextBox', testData, 'Passed',
                               'Failed', 'Enter value into password textbox',
                               'ExitTest', 'WaitTime')
        GF_Obj.clickOnWebObj('Login_Login_Btn', 'HomePage', 'Passed', 'Failed',
                             'Click on Login button', 'ExitTest', 'WaitTime')

        # Step 3
        # ==============================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Select "" from sex dropdown in homepage'
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ==============================================================
        #GF_Obj.setValToObj('HomePage_ViewLarge_ChooseFile', '‪C:/Users/Dell/Desktop/Sample.png', 'Passed', 'Failed', 'Enter value into user id textbox',
        # 'ExitTest', 'WaitTime')

        GF_Obj.clickOnWebObj(
            'HomePage_ViewLarge_ChooseFile', '', 'Passed', 'Failed',
            'Click on "Choose File" button under View Large Section  in Home page',
            'ExitTest', 'WaitTime')
        time.sleep(3)

        GF_Obj.closeAllBrowser('Yes')
    except Exception as e:
        pass
Ejemplo n.º 2
0
def TC_004_WebTable():
    try:
        reportStep = ''
        waitTime = ''
        exitTestOnStepFail = True
        dontExitTestOnStepFail = False
        globVal.testCaseName = 'TC_004_WebTable'
        globVal.testType = 'Regression'
        globVal.testBrowser = 'chrome'
        globVal.testURL = 'https://chercher.tech/python/table-selenium-python#'

        # Creating object to global function
        GF_Obj = GlobalFunction()

        testData = GF_Obj.getDataFromDataSheet(
            '', globVal.testData_TestData_SheetName, 'TC_001_Login',
            'UserName', 'passed', 'failed', reportStep, dontExitTestOnStepFail,
            3)
        # Step 1
        # ==============================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Open the browser and Navigate to ' + globVal.testURL
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ==============================================================
        GF_Obj.launchApplication(globVal.testBrowser, globVal.testURL,
                                 waitTime)
        #GF_Obj.verifyWebObjDisplayed('SignUp_page', 'Passed', 'Failed', 'stepName', 'ExitTest', 'WaitTime')
        object = globVal.driver.find_element_by_id('webtable')
        globVal.stepDiscription = 'CherCherTech - WebTable'
        GF_Obj.verifyWebObjDisplayed(object, 'Passed', 'Failed', reportStep,
                                     waitTime, dontExitTestOnStepFail)
        GF_Obj.verifyWebObjDisplayed('CherCherTech_Table_WebElement', 'Passed',
                                     'Failed', reportStep, waitTime,
                                     exitTestOnStepFail)

        GF_Obj.verifyWebObjEnabled('CherCherTech_JIRA_Link', 'passed',
                                   'failed', reportStep, waitTime,
                                   dontExitTestOnStepFail)
        #GF_Obj.clickOnWebObj('CherCherTech_JIRA_Link','','passed','failed',reportStep,waitTime,dontExitTestOnStepFail)
        GF_Obj.clickOnWebObj('CherCherTech_JIRA_Link',
                             'CherCherTech_JIRA_Page', 'passed', 'failed',
                             reportStep, waitTime, exitTestOnStepFail)
        globVal.driver.back()

        Result = GF_Obj.getRowCountOfWebTable('CherCherTech_Table_WebElement',
                                              'passed', 'failed', reportStep,
                                              dontExitTestOnStepFail, waitTime)
        print('Total Rows', Result)
        Result = GF_Obj.getColumnCountOfWebTable(
            'CherCherTech_Table_WebElement', 'passed', 'failed', reportStep,
            dontExitTestOnStepFail, waitTime)
        print('Total Columns', Result)
        Result = GF_Obj.getCellDataFromWebTable(
            'CherCherTech_Table_WebElement', 2, 3, 'passed', 'failed',
            reportStep, dontExitTestOnStepFail, waitTime)
        print('Cell value', Result)
        Result = GF_Obj.verifyWebTableCellExist(
            'CherCherTech_Table_WebElement', 2, 3, 'passed', 'failed',
            reportStep, waitTime, dontExitTestOnStepFail)
        print('Cell Present', Result)
        Result = GF_Obj.getCellDataFromWebTable(
            'CherCherTech_Table_WebElement', 2, 3, 'passed', 'failed',
            reportStep, dontExitTestOnStepFail, waitTime)
        print('Cell value', Result)
        Result = GF_Obj.getTotalDataOfWebTable('CherCherTech_Table_WebElement',
                                               'passed', 'failed', reportStep,
                                               dontExitTestOnStepFail,
                                               waitTime)
        print('Total value', Result)
        Result = GF_Obj.verifyWebObjEnabled('CherCherTech_Link1_Link',
                                            'passed', 'failed', reportStep,
                                            dontExitTestOnStepFail, waitTime)
        print('Is Enabled', Result)
        Result = GF_Obj.verifyWebObjDisplayed('CherCherTech_Link2_Link',
                                              'passed', 'failed', reportStep,
                                              dontExitTestOnStepFail, waitTime)
        print('Is Displayed', Result)
        GF_Obj.closeAllBrowser(False)

        globVal.testURL = 'https://www.thetestingworld.com/testings/'
        # Step 2
        # ==============================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Open the browser and Navigate to ' + globVal.testURL
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ==============================================================
        GF_Obj.launchApplication(globVal.testBrowser, globVal.testURL,
                                 waitTime)

        # Step 3
        # ====================================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Login to the application'
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ===================================================================
        GF_Obj.clickOnWebObj('SignUp_Login_Link', '', 'Passed', 'Failed',
                             'Click on Login link in SignUp page', waitTime,
                             dontExitTestOnStepFail)
        testData = GF_Obj.getDataFromDataSheet(
            '', globVal.testData_Credentials_SheetName, 'TestingWorld',
            'UserName', 'Passed', 'Failed', reportStep, dontExitTestOnStepFail,
            1)
        GF_Obj.setDataToWebObj('Login_UserID_TextBox', testData, 'Passed',
                               'Failed', 'Enter value into user id textbox',
                               waitTime, dontExitTestOnStepFail)
        testData = GF_Obj.getDataFromDataSheet(
            '', globVal.testData_Credentials_SheetName, 'TestingWorld',
            'Password', 'Passed', 'Failed', reportStep, dontExitTestOnStepFail,
            1)
        GF_Obj.setDataToWebObj('Login_Password_TextBox', testData, 'Passed',
                               'Failed', 'Enter value into password textbox',
                               waitTime, dontExitTestOnStepFail)
        GF_Obj.clickOnWebObj('Login_Login_Btn', '', 'Passed', 'Failed',
                             'Click on Login button', waitTime,
                             dontExitTestOnStepFail)

        # Step 4
        # ==============================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Select "Female" from sex dropdown in homepage'
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ==============================================================
        # GF_Obj.selectDropdownWebObjValByName('HomePage_Sex_Dropdown', 'Female', 'Passed', 'Failed', reportStep,
        #                                      waitTime, dontExitTestOnStepFail)
        GF_Obj.selectDropdownWebObjValByIndex('HomePage_Sex_Dropdown', 2,
                                              'Passed', 'Failed', reportStep,
                                              waitTime, dontExitTestOnStepFail)
        GF_Obj.closeAllBrowser('Yes')
    # Catch if Exception is occurred
    except Exception as e:
        exceptionType = str(type(e).__name__)
        if exceptionType.lower() != 'exception':
            # Report Step as 'Failed'
            stepName = 'Exception occurred in test execution. (ExceptionType: <' + exceptionType + '>)'
            stepDetail = 'Description: <' + str(e) + '>'
            Report.customReport(stepName, stepDetail, 'Failed')
            # Save HTML Report
            GF_Obj.saveHTMLReport()
        else:
            pass
def TC_002_Signup():
    try:
        globVal.testCaseName = 'TC_002_Signup'
        globVal.testType = 'Regression'

        #Creating object to global function
        GF_Obj = GlobalFunction()

        #Step 1
        # ==============================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Open the browser and Navigate to ' + globVal.testURL
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ==============================================================
        GF_Obj.launchApplication()
        GF_Obj.verifyWebObjDisplayed('SignUp_page', 'Passed', 'Failed',
                                     'StepName', 'ExitTest', 'WaitTime')

        # Step 2
        # ==============================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Signup with valid details'
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ==============================================================
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_TestData_SheetName,
            globVal.testCaseName, 'UserName', 'Passed', 'Failed', 'StepName',
            'ExitTest')
        GF_Obj.setDataToWebObj('SignUp_UserName_TextBox', testData, 'Passed',
                               'Failed', 'Enter User name into textbox',
                               'ExitTest', 'WaitTime')
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_TestData_SheetName,
            globVal.testCaseName, 'EmailId', 'Passed', 'Failed', 'StepName',
            'ExitTest')
        GF_Obj.setDataToWebObj('SignUp_MailId_TextBox', testData, 'Passed',
                               'Failed', 'Enter Maild id into textbox',
                               'ExitTest', 'WaitTime')
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_Credentials_SheetName, 'TestingWorld',
            'Password', 'Passed', 'Failed', 'StepName', 'ExitTest')
        GF_Obj.setDataToWebObj('SignUp_Password_TextBox', testData, 'Passed',
                               'Failed', 'Enter password into textbox',
                               'ExitTest', 'WaitTime')
        GF_Obj.setDataToWebObj('SignUp_CnfPassword_TextBox', testData,
                               'Passed', 'Failed',
                               'Enter confirm password into textbox',
                               'ExitTest', 'WaitTime')
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_TestData_SheetName,
            globVal.testCaseName, 'DateOfBirth', 'Passed', 'Failed',
            'StepName', 'ExitTest')
        GF_Obj.setDataToWebObj('SignUp_DateOfBirth_TextBox', testData,
                               'Passed', 'Failed',
                               'Enter Date of birth into textbox', 'ExitTest',
                               'WaitTime')
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_TestData_SheetName,
            globVal.testCaseName, 'PhoneNumber', 'Passed', 'Failed',
            'StepName', 'ExitTest')
        GF_Obj.setDataToWebObj('SignUp_PhoneNumber_TextBox', testData,
                               'Passed', 'Failed',
                               'Enter Phone Number into textbox', 'ExitTest',
                               'WaitTime')
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_TestData_SheetName,
            globVal.testCaseName, 'Address', 'Passed', 'Failed', 'StepName',
            'ExitTest')
        GF_Obj.setDataToWebObj('SignUp_Address_TextBox', testData, 'Passed',
                               'Failed', 'Enter Address into textbox',
                               'ExitTest', 'WaitTime')
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_TestData_SheetName,
            globVal.testCaseName, 'AddressType', 'Passed', 'Failed',
            'StepName', 'ExitTest')
        if str(testData).lower() == 'home':
            obj = 'SignUp_Home_RadioBtn'
        elif str(testData).lower() == 'office':
            obj = 'SignUp_Office_RadioBtn'
        else:
            obj = None
            Report.customReport(
                'Select address type',
                'Entered address type in "TestData.xlsx" is invalid', 'Failed')
            GF_Obj.stopExecution()
        GF_Obj.clickOnWebObj(obj, '', 'Passed', 'Failed',
                             'Select Address type in SignUp page', 'ExitTest',
                             'WaitTime')
        GF_Obj.selectDropdownWebObjValByName('SignUp_Gender_DropDown', 'Male',
                                             'Passed', 'Failed',
                                             'Select Gender from dropdown',
                                             'ExitTest', 'WaitTime')
        GF_Obj.selectDropdownWebObjValByName('SignUp_Country_DropDown',
                                             'India', 'Passed', 'Failed',
                                             'Select Country from dropdown',
                                             'ExitTest', 'WaitTime')
        GF_Obj.selectDropdownWebObjValByName('SignUp_State_DropDown',
                                             'Andhra Pradesh', 'Passed',
                                             'Failed',
                                             'Select State from dropdown',
                                             'ExitTest', 'WaitTime')
        GF_Obj.selectDropdownWebObjValByName('SignUp_City_DropDown',
                                             'Anantapur', 'Passed', 'Failed',
                                             'Select City from dropdown',
                                             'ExitTest', 'WaitTime')
        testData = GF_Obj.getDataFromDataSheet(
            'filepath', globVal.testData_TestData_SheetName,
            globVal.testCaseName, 'Zipcode', 'Passed', 'Failed', 'StepName',
            'ExitTest')
        GF_Obj.setDataToWebObj('SignUp_ZipCode_TextBox', testData, 'Passed',
                               'Failed', 'Enter Zipcode into textbox',
                               'ExitTest', 'WaitTime')
        GF_Obj.clickOnWebObj('SignUp_Terms_CheckBox', '', 'Passed', 'Failed',
                             'StepName', 'ExitTest', 'WaitTime')

        GF_Obj.clickOnWebObj('SignUp_SignUp_Btn', '', 'Passed', 'Failed',
                             'StepName', 'ExitTest', 'WaitTime')
        # GF_Obj.verifyWebObj('HomePage_Logout_Btn','Passed','Failed','Verify Home page is displayed','ExitTest','WaitTime')
        try:
            message = globVal.driver.find_element_by_xpath(
                '//div[@id="tab-content1"]/div').text
            if 'User is successfully Register. Now You can Login' in message:
                Report.customReport('Verify user successfully signed up',
                                    'User successfully signed up', 'Passed')
            else:
                Report.customReport(
                    'Verify user successfully signed up',
                    'User is not successfully signed up Error is : "' +
                    str(message) + '"', 'Failed')
        except Exception as error:
            Report.customReport(
                'Verify user successfully signed up',
                'User is not successfully signed up. Error is : "' +
                str(error) + '"', 'Failed')

        # Step 3
    # ==============================================================
        globVal.stepNumber = globVal.stepNumber + 1
        globVal.stepName = 'Close all the browsers'
        Report.customReportStepNum(globVal.stepNumber, globVal.stepName)
        # ==============================================================
        GF_Obj.closeAllBrowser('Yes')
    except Exception as e:
        pass