QTP Framework:- Web common functions sampel examples using QTP

Web common functions using QTP

' Function Name :Invoke_URL
' In Parameters :
' Out Parameters :
' Description :Invokes Url
'*******************************************************************************************************************************************************************************************
Option Explicit   ' Force explicit variable declaration.

Function Invoke_URL(param_array)
On Error resume next

    'f_log.WriteLine "INFO <Invoke_URL>Entering the keyword Invoke_URL"
    'Fetch the URL
    site = param_array
        'Format the URL by removing the spaces and converting the string to lowercase
    'site = FormatInput(site)
        'Create an IE browser object and invoke the URL
        Set Brow_invok = createobject("InternetExplorer.Application")
        Brow_invok.Visible = True
        Brow_invok.Navigate site
        wait(2)
        'Close the security Alert If popped up.
    Maximize (Brow_invok)
    'f_log.WriteLine "INFO <Invoke_URL>Exiting the keyword Invoke_URL"
End Function

'*******************************************************************************************************************************************************************************************
' Function Name :Maximize
' In Parameters :
' Out Parameters :
' Description :Maximises Window
'*******************************************************************************************************************************************************************************************
Function Maximize(windw)
    'f_log.WriteLine "INFO <Maximize>Entering the keyword Maximize"
    On Error resume next
   If Browser(windw).Exist Then
       hwnd = Browser(windw).GetROProperty("hwnd")
       Browser("hwnd:=" & hwnd).FullScreen
    Report "PASS", "NewScale RequestCenter Browser", "NewScale RequestCenter Browser displayed successfully"
    Else
    Report "FAIL", "NewScale RequestCenter Browser", "NewScale RequestCenter Browser was not Displayed"
   End If
    'f_log.WriteLine "INFO <Maximize>Exiting the keyword Maximize"        
End Function

''**************************************************************************************************
''Function Name: Select_Combo
''Parameter    : Action Name, Drop Down Object, Value   
''Author          :
''Description  :
''**************************************************************************************************
'Public Function Select_Combo(Combo_Object, Combo_Value)
'    'f_log.WriteLine "INFO <Select_Combo>Entering the keyword Select_Combo"
'    objectName=Combo_Object.GetROproperty("name")
'    stepName="Select Drop Down List"
'    passDesc=objectName+Combo_Value+"was selected from the List"
'    failDesc=objectName+"Drop Down List object was not found"
'
'    If Combo_Object.Exist then
'        If  Combo_Object.GetROProperty("disabled") = False Then
'       
'          Combo_Object.Select Combo_Value
'            Report "Pass",stepName,passDesc
'            'f_log.WriteLine "PASS <"&passDesc&">"
'    else
'            'f_log.WriteLine "FAIL < Combo List  field object is disabled>"
'            Report "Fail",stepName, objectName+" Combo List  field object is disabled"
'    End If
'    Else
'            'f_log.WriteLine "FAIL <"&failDesc&">"
'              Report "Fail",stepName,failDesc
'    end if   
'   
'    'f_log.WriteLine "INFO <Select_Combo>Exiting the keyword Select_Combo"
'End Function

'**************************************************************************************************
'Function Name: Select_Combo
'Parameter : Action Name, Drop Down Object, Value
'Author :
'Description :
'**************************************************************************************************
Public Function Select_Combo(Combo_Object, Combo_Value)
'f_log.WriteLine "INFO <Select_Combo>Entering the keyword Select_Combo"
objectName=Combo_Object.GetROproperty("name")
stepName="Select Drop Down List"
passDesc=objectName+Combo_Value+"was selected from the List"
failDesc=objectName+"Drop Down List object was not found"

If Combo_Object.Exist then
If Combo_Object.GetROProperty("disabled") = False Then
all_items = Combo_Object.GetROProperty("all items")
item_value = Split(all_items, ";")
Number_items = Ubound(item_value)
'msgbox Number_items
For i=0 to Ubound(item_value)
'msgbox item_value(i)
If cstr(trim(Combo_Value)) = cstr(Trim(item_value(i))) Then

Combo_Object.Select Combo_Value
Report "Pass",stepName,passDesc
Exit For
Else
Reporter.ReportEvent micDone,"Item Specified", "Item Specified was not Found in the list"
End If
Next
else
'f_log.WriteLine "FAIL < Combo List field object is disabled>"
Report "Fail",stepName, objectName+" Combo List field object is disabled"
End If
Else
'f_log.WriteLine "FAIL <"&failDesc&">"
Report "Fail",stepName,failDesc
end if

'f_log.WriteLine "INFO <Select_Combo>Exiting the keyword Select_Combo"
End Function

'*******************************************************************************************************************************************************************************************
' Function Name :Close_Browsers
' In Parameters :
' Out Parameters :
' Description :Closes the Browser
'*******************************************************************************************************************************************************************************************

Function Close_Browsers
    'f_log.WriteLine "INFO <Close_Browsers>Entering the keyword Close_Browsers"
    On Error resume next
    Set service = GetObject ("winmgmts:")
     For Each Process in Service.InstancesOf ("Win32_Process")

            If Process.Name = "IEXPLORE.EXE" then
                Process.Terminate(0)
            End If
    Next
    While Browser("micClass:=browser","index:=0").Exist(5)
        Browser("micClass:=browser","index:=0").Close
    WEnd
   ' f_log.WriteLine "INFO <Close_Browsers>Exiting the keyword Close_Browsers"
End Function

'**************************************************************************************************
'Function Name: Edit_Set
'Parameter    : Text field Object, Value   
'Author       :
'Description  :
'**************************************************************************************************

Public Function Edit_Set(Edit_Object, Edit_Value)
    'f_log.WriteLine "INFO <Edit_Set>Entering the keyword Edit_Set"
    objectName=Edit_Object.GetROproperty("name")
    stepName="Enter Text Field"
    passDesc=Edit_Value+" value was entered in '"+objectName+"' Edit Field"
    failDesc=objectName+" Text field object was not found"
   
    if Edit_Value <> "" then
    If Edit_Object.Exist(5) then
          If  Edit_Object.GetROProperty("disabled") = False Then
        Edit_Object.Set Edit_Value
        'f_log.WriteLine "PASS <"&passDesc&">"
        Report "Pass",stepName,passDesc
    else
        'f_log.WriteLine "FAIL <" Text field object is disabled">"
      Report "Fail",stepName,objectName+" Text field object is disabled"
    End If
    Else
        'f_log.WriteLine "FAIL <"&failDesc&">"
        Report "Fail",stepName,failDesc
    end if   
    end if   
   
    'f_log.WriteLine "INFO <Edit_Set>Exiting the keyword Edit_Set"
End Function

'*******************************************************************************************************************************
'Function Name: Click_Button
'Parameter    : Button Object   
'Author       :
'Description  :
'*******************************************************************************************************************************

Public Function Click_Button(Button_Object)
    'f_log.WriteLine "INFO <Click_Button>Entering the keyword Click_Button"
    objectName=Button_Object.GetROproperty("name")
    stepName=objectName
    passDesc=objectName+" was Clicked successfully"
    failDesc=objectName+" object was not found "

        If Button_Object.Exist then
            If  Button_Object.GetROProperty("disabled") = False Then
            Button_Object.Click
            'f_log.WriteLine "PASS <"&passDesc&">"
            Report "Pass",stepName,passDesc
            else
              'f_log.WriteLine "FAIL <Button object is disabled>"
            Report "Fail",stepName,objectName+" Button object is disabled"
            End If
    Else
            'f_log.WriteLine "FAIL <"&failDesc&">"
            Report "Fail",stepName,failDesc
        end if
     
    'f_log.WriteLine "INFO <Click_Button>Exiting the keyword Click_Button"
End Function


'*******************************************************************************************************************************
'Function Name: Click_Link
'Parameter    : Button Object   
'Author       :
'Description  :
'*******************************************************************************************************************************

Public Function Click_Link(Link_Object)
    'f_log.WriteLine "INFO <Click_Link>Entering the keyword Click_Link"
    objectName=Link_Object.GetROProperty("name")
    stepName=objectName
    passDesc=objectName+" was Clicked successfully"
    failDesc=objectName+" object was not found "

        If Link_Object.Exist then
            If  Link_Object.GetROProperty("disabled") = False Then
            Link_Object.Click
            'f_log.WriteLine "PASS <"&passDesc&">"
            Report "Pass",stepName,passDesc
            else
             'f_log.WriteLine "FAIL< Link object is disabled>"
            Report "Fail",stepName,objectName+" Link object is disabled"
        End If
        else
            'f_log.WriteLine "FAIL<"&failDesc&">"
            Report "Fail",stepName,failDesc
        end if
       
    'f_log.WriteLine "INFO <Click_Link>Exiting the keyword Click_Link"

End Function

'*******************************************************************************************************************************
'Function Name: Click_Element
'Parameter    : Button Object   
'Author       :
'Description  :
'*******************************************************************************************************************************

Public Function Click_Element(Element_Object)
    'f_log.WriteLine "INFO <Click_Element>Entering the keyword Click_Element"
    objectName=Element_Object.GetROproperty("innertext")
    stepName=objectName
    passDesc=objectName+" was Clicked successfully"
    failDesc=objectName+" object was not found "

    If Element_Object.Exist then
         If  Element_Object.GetROProperty("disabled") = False Then
        Element_Object.Click
        'f_log.WriteLine "PASS <"&passDesc&">"
        Report "Pass",stepName,passDesc
        else
        Report "Fail",stepName,objectName+" Element object is disabled"
     End If
      Else
        'f_log.WriteLine "FAIL<"&failDesc&">"
        Report "Fail",stepName,failDesc
    end if
  
    'f_log.WriteLine "INFO <Click_Element>Exiting the keyword Click_Element"
End Function

'*******************************************************************************************************************************
'Function Name: Click_Image
'Parameter    : Button Object   
'Author       :
'Description  :
'*******************************************************************************************************************************

Public Function Click_Image(Image_Object)
    'f_log.WriteLine "INFO <Click_Image>Entering the keyword Click_Image"
    objectName=Image_Object.GetROproperty("alt")
    stepName=objectName
    passDesc=objectName+" was Clicked successfully"
    failDesc=objectName+" object was not found "

    If Image_Object.Exist then
        If  Image_Object.GetROProperty("disabled") = False Then
        Image_Object.Click
       
        'f_log.WriteLine "PASS <"&passDesc&">"
        Report "Pass",stepName,passDesc
        else
         'f_log.WriteLine "FAIL<Element object is disabled>"
        Report "Fail",stepName,objectName+" Image object is disabled"
     End If
        Else
        'f_log.WriteLine "FAIL<"&failDesc&">"
        Report "Fail",stepName,failDesc
    end if
   
    'f_log.WriteLine "INFO <Click_Image>Exiting the keyword Click_Image"
End Function

'*******************************************************************************************************************************
'Function Name: Set_CheckBox
'Parameter    : Tab Object, Value    
'Author          :
'Description  :
'*******************************************************************************************************************************

Public Function Set_CheckBox(Check_Object,Check_Value)
    'f_log.WriteLine "INFO <Set_CheckBox>Entering the keyword Set_CheckBox"
    objectName=Check_Object.GetROProperty("name")
    stepName="Set Check Box"
    passDesc=objectName+Check_Value+" was Selected successfully"
    failDesc=objectName+" object was not found "
  
     if Check_Value <> "" then
         If Check_Object.Exist then
             If  Check_Object.GetROProperty("disabled") = False Then
            Check_Object.Set Check_Value
            'f_log.WriteLine "PASS <"&passDesc&">"
            Report "Pass",stepName,passDesc
            else
            
            Report "Fail",stepName,objectName+" Check Box object is disabled"
        End If
         else
            'f_log.WriteLine "FAIL <"&failDesc&">"
            Report "Fail",stepName,failDesc
            end if
           end if
    'f_log.WriteLine "INFO <Set_CheckBox>Exiting the keyword Set_CheckBox"
End Function

'*******************************************************************************************************************************
'Function Name: Select_Radiobutton
'Parameter    :  Object, Value    
'Author          :
'Description  :
'*******************************************************************************************************************************

Public Function Select_Radiobutton(Radio_Object, Radio_Value)
    'f_log.WriteLine "INFO <Select_Radiobutton>Entering the keyword Select_Radiobutton"
    objectName=Radio_Object.GetROProperty("name")
    stepName="Select Radio Button"
    passDesc=objectName+" was Selected successfully"
    failDesc=objectName+" object was not found "
  
    if objectName <> "" then
        If Radio_Object.Exist then
             If  Radio_Object.GetROProperty("disabled") = False Then
            Radio_Object.Select Radio_Value
            'f_log.WriteLine "PASS <"&passDesc&">"
            Report "Pass",stepName,passDesc
            else
            'f_log.WriteLine "FAIL <"&objectName&"Radio Button object is disabled>"
             Report "Fail",stepName,objectName+" Radio Button object is disabled"
        End If
        Else
            'f_log.WriteLine "FAIL <"&failDesc&">"
            Report "Fail",stepName,failDesc
        end if
        end if
    'f_log.WriteLine "INFO <Select_Radiobutton>Exiting the keyword Select_Radiobutton"
End Function

'*******************************************************************************************************************************
'Function Name: Verify_Edit
'Parameter    :
'Author          :
'Description  :
'*******************************************************************************************************************************

Public Function Verify_Edit(Edit_Object,Edit_Value)
    'f_log.WriteLine "INFO <Verify_Edit>Entering the keyword Verify_Edit"
    objectName=Edit_Object.getROProperty("name")
If  objectName=" " then
    objectName=Edit_Object.getROProperty("html id")
    end if
   
    stepName="Verification of "+objectName+" Edit Field"

    If Edit_Object.Exist then
        If  Edit_Object.GetROProperty("disabled") = False Then
        ret=Edit_Object.GetROProperty("value")
            if instr(ret,Edit_Value) > 0 then
        'f_log.WriteLine "PASS <INFO>Expected Result of Edit Field is same as Actual Result value is "&ret
               Report "Pass",stepName,"Expected Result of    "&Edit_Value&"  in " & objectName& "   Edit Field  matched  with the Actual Result Value is "&ret
                elseif Edit_Value = ret then
                'f_log.WriteLine "PASS <INFO>Expected Result of Edit Field is same as Actual Result value>"
               Report "Pass",stepName,"Expected Result of    "&Edit_Value&"   in " & objectName& "   Edit Field  matched  with the Actual Result Value is "&ret
                else
                'f_log.WriteLine "FAIL <INFO>Expected Result of Edit Field did not match with the Actual Result value is "&ret
                Report "Fail",stepName,"Expected Result of     "&Edit_Value&"   in " & objectName& "   Edit Field did not match  with the Actual Result Value is "&ret
            end if   

    else
      Report "Fail",stepName,"Expected     "&Edit_Object&"    Edit Field object is disabled"
        End If
        Else
        'f_log.WriteLine "FAIL < Edit Field was not found for Verification>"
        Report "Fail",stepName," Edit Field " &Edit_Object&"was not found for Verification"
    end if
    'f_log.WriteLine "INFO <Verify_Edit>Exiting the keyword Verify_Edit"
End Function

'*******************************************************************************************************************************
'Function Name: Verify_Combo
'Parameter    :
'Author          :
'Description  :
'*******************************************************************************************************************************

Public Function Verify_Combo(Combo_Object, Combo_Value)
    'f_log.WriteLine "INFO <Verify_Combo>Entering the keyword Verify_Combo"
     objectName=Combo_Object.GetROproperty("name")
     stepName="Verification of "+objectName+" drop down combo"
  
    If Combo_Object.Exist then
        If  Combo_Object.GetROProperty("disabled") = False Then
        ret=Combo_Object.GetROProperty("value")
        if instr(ret,Combo_Value) > 0 then
        'f_log.WriteLine "PASS <Expected Result of List Field is same as Actual Result, value is "&ret&">"
        Report "Fail",stepName,"Expected Result of List Field  " &Combo_Object&"is "  &Combo_Value&"   matched  with the Actual Result, value is "+ret
            else
        'f_log.WriteLine "FAIL <Expected Result of List Field did not match with the Actual Result, value is "+ret+">"
        Report "Fail",stepName,"Expected Result of List Field  " &Combo_Object&"is "  &Combo_Value&"   did not match with the Actual Result, value is "+ret
        end if
            else
          'f_log.WriteLine "FAIL <Drop Down combo object is disabled>"
        Report "Fail",stepName,objectName+" Drop Down combo object is disabled"
        End If
        Else
        'f_log.WriteLine "FAIL <Drop Down combo object  not found for Verification>"
        Report "Fail",stepName,"Drop Down combo object  not found for Verification"
    end if
    'f_log.WriteLine "INFO <Verify_Combo>Exiting the keyword Verify_Combo"
End Function

'*******************************************************************************************************************************
'Function Name: Verify_Button
'Parameter    :
'Author          :
'Description  :
'*******************************************************************************************************************************

Public Function Verify_Button(Button_Object, Button_Name)
    'f_log.WriteLine "INFO <Verify_Button>Entering the keyword Verify_Button"
    If Button_Object.Exist then
        If  Button_Object.GetROProperty("disabled") = False Then
            ret=Button_Object.GetROProperty("name")
             If instr(ret,Button_Name) > 0 then
            'f_log.WriteLine "PASS <Expected Result of Button is same as Actual Result, value is "&ret&">"
            Report "Pass","Verification of "+Button_Name+" Button ","Expected Result of Button is same as Actual Result, value is "+ret
            else
             'f_log.WriteLine "FAIL <Expected Result of Button did not match with the Actual Result, value is "&ret&">"
            Report "Fail","Verification of "+Button_Name+" Button ","Expected Result of Button did not match with the Actual Result, value is "+ret
            end if   
   
        else
        'f_log.WriteLine "FAIL <Button object is disabled>"
        Report "Fail",stepName,objectName+" Button object is disabled"
        End If
    else
        'f_log.WriteLine "FAIL <Button object was not found for Verification>"
        Report "Fail","Button Object ","Button Object was not found for Verification"
    end if
     'f_log.WriteLine "INFO <Verify_Button>Exiting the keyword Verify_Button"
End Function

'*******************************************************************************************************************************
'Function Name: Verify_Link
'Parameter    :
'Author          :
'Description  :
'*******************************************************************************************************************************

Public Function Verify_Link(Link_Object)
   objectname = Link_Object.GetROproperty("name")
    If Link_Object.Exist then
        If  Link_Object.GetROProperty("disabled") = False Then
        Report "Pass","Link name "&objectname&""," Link name "&objectname&" was found for Verification"
    else
         'f_log.WriteLine "FAIL <Link object is disabled>"
        Report "Fail",objectName,objectName+" Link object is disabled"
        End If
        else
        Report "Fail","Link name "&objectname&""," Link name "&objectname&" was not found for Verification"
    end if

End Function

'*******************************************************************************************************************************
'Function Name: Verify_Element
'Parameter    :
'Author          :
'Description  :
'*******************************************************************************************************************************

Public Function Verify_Element(Element_Object)
   objectname = Element_Object.GetROproperty("name")
  
    If Element_Object.Exist then
         If  Element_Object.GetROProperty("disabled") = False Then
        Report "Pass","Verification of  "&objectname&" Element ","Element Object  "&objectname&" was  found for Verification"
        else
      'f_log.WriteLine "FAIL <Link object is disabled>"
        Report "Fail",objectName,objectName+" Link object is disabled"
           End If
     Else      
        Report "Fail","Element Object  "&objectname&"","Element Object  "&objectname&" was not found for Verification"
    end if

End Function

'*******************************************************************************************************************************
'Function Name: Verify_CheckBox
'Parameter    :
'Author          :
'Description  :
'*******************************************************************************************************************************

Public Function Verify_CheckBox(Link_Object, Link_Name)
    Objectname = Link_Name
  
    If Link_Object.Exist then
       
        If  Link_Object.GetROProperty("disabled") = "1" Then

             Report "Pass", Objectname, "is Disabled"
           
            Else
        Dim CheckBoxButtonValue_Array(2)
            CheckBoxButtonValue_Array(0) = "ON"
            CheckBoxButtonValue_Array(1) = "OFF"
            checkedStatus =  Link_Object.GetROProperty("value")
            Report "Pass", Objectname, "is "&CheckBoxButtonValue_Array(checkedStatus)
       
        End if
     End If
End Function

'*******************************************************************************************************************************
'Function Name: Verify_Radio
'Parameter    : Radio button object, Expected selection item index
'Author          : Testing czars
'Description  : This function verifies the expected and actual 'selected item index ' of the web radio button object
'*******************************************************************************************************************************

Public Function Verify_Radio(Radio_Object, Radio_Value)

Objectname = Radio_Object.GetROProperty("name") 
Select_Value = Radio_Object.GetROPreperty("selected item index")
If  Select_Value = Radio_Value Then

                Report "Pass", Objectname, "For "& Objectname &"The selected item index is '"& Radio_Value &"'."
Else

                Report "Fail", Objectname, "For "& Objectname &"The selected item index is '"& Radio_Value &"', but the expected is '"& Select_Value &"'."               
End If
End Function

'*******************************************************************************************************************************
'Function Name: FormatInput
'Parameter    : Tab Object, Value    
'Author          :
'Description  :
'*******************************************************************************************************************************
Public Function FormatInput(input_string)
   'f_log.WriteLine "INFO <FormatInput>Entering the keyword FormatInput"
    'On Error resume next
    'remove the spaces
    input_string = replace(input_string," ","")
    'convert the string to lower case
    input_string = lcase(input_string)
   
    If instr(input_string,"[comment]") > 0 Then
        input_string = "comment"
    End If
    Set FormatInput = Description.Create
    FormatInput = input_string
    'f_log.WriteLine "INFO <FormatInput>Entering the keyword FormatInput"
End Function

'*******************************************************************************************************************************
'Function Name: Report
'Parameter    :
'Author          :
'Description  :
'*******************************************************************************************************************************

Public Function Report(status,stepName,stepDescription)

If status="Pass" Then
Reporter.ReportEvent micPass,stepName,stepDescription

'This is for writing results to excel
            strStep = stepName
            strActRes = stepDescription
            strStatus = "PASS"
            reportResult dtsSheet
           
elseIf status = "Fail" Then
Reporter.ReportEvent micFail,stepName,stepDescription

'This is for writing results to excel
            strStep = stepName
            strActRes = stepDescription
            strStatus = "FAIL"
            reportResult dtsSheet
End If
End Function

'*******************************************************************************************************************************************************************************************
' Function Name : newScaleLogin
' In Parameters : 
' Out Parameters :
' Description : Logs In to the NewScale RequestCenter  Application
'*******************************************************************************************************************************************************************************************
Public Function newScaleLogin(username,password)
 'f_log.WriteLine "INFO <newScaleLogin>Entering the keyword newScaleLogin"
 Set Edit_Object= Browser("newScale RequestCenter").Page("newScale - Login").WebEdit("NSA_LOGIN_NAME")
 Edit_Value = username
 Edit_Set Edit_Object, Edit_Value

 Set Edit_Object=Browser("newScale RequestCenter").Page("newScale - Login").WebEdit("NSA_PASSWORD")
 Edit_Value = password
 Edit_Set Edit_Object, Edit_Value

 Set Button_Object = Browser("newScale RequestCenter").Page("newScale - Login").WebButton("Login")
Click_Button Button_Object

Browser("newScale RequestCenter").Page("newScale - Login").Sync

 If   Browser("newScale RequestCenter").Page("newScale RequestCenter").WebElement("newScale RequestCenter").Exist Then
      'f_log.WriteLine "PASS <"&username&" loginid and "&password&" password was logged in sucessfully>" 
     Report "Pass", "New Scale Login", username&" loginid and "&password&" password was logged in sucessfully"
    Else
    'f_log.WriteLine "FAIL<"&username&" loginid and "&password&" password was incorrect and Login was unsucessfull>"
    Report "Fail", "New Scale Login", username&" loginid and "&password&" password was incorrect and Login was unsucessfull"
    End If

 'f_log.WriteLine "INFO <newScaleLogin>Exiting the keyword newScaleLogin"   
End Function

'*******************************************************************************************************************************
'Function Name: newscaleRequestCenter_Logout
'Parameter    :  Table_Name
'Description  :
'*******************************************************************************************************************************
Public Function newscaleRequestCenter_Logout
    'f_log.WriteLine "INFO <newscaleRequestCenter_Logout>Exiting the keyword newscaleRequestCenter_Logout"
   
   'Calling Function for Clicking Link Logout
   Set Link_Object = Browser("newScale RequestCenter").Page("newScale RequestCenter_3").Link("Logout")
   Click_Link Link_Object

   'Verifying the Login button displayed after LogOut
    Set Button_Object = Browser("newScale RequestCenter").Page("newScale - Login").WebButton("Login")
    Verify_Button Button_Object, Button_Name

    'Calling Function for clicking on Login Button
    Set Button_Object = Browser("newScale RequestCenter").Page("newScale - Login").WebButton("Login")
    Click_Button Button_Object

    If Browser("newScale RequestCenter").Page("newScale - Login").Exist Then
        Browser("newScale RequestCenter").Close
    End If

    Close_Browsers
   'f_log.WriteLine "INFO <newscaleRequestCenter_Logout>Exiting the keyword newscaleRequestCenter_Logout"
End Function

'********************************************************************************************************************************************************************************************************************
'Funcition Name : WebTable_VerifyLink
'parameters: parameter one - table_object hireachry,parameter two - link name,parameter three - Number of pages to search example : 24/10 = 3 pages
'Description -  Used to Verify Link text  for Organisation Unit, People, Queues, ROles, Groups, Functional Positions on left hand side of the page
'
'********************************************************************************************************************************************************************************************************************

Function WebTable_VerifyLink(table_Object,linkname,pagecount,module)
'Set table_Object=tbl_obj
'Set table_object=Browser("newScale RequestCenter").Page("newScale RequestCenter_2").WebTable("Name")
For i=1 to pagecount'-1
rcount=table_object.RowCount
For k=2 to rcount
    'msgbox rcount
'    ccount=Browser("newScale RequestCenter").Page("newScale RequestCenter").WebTable("Name").ColumnCount(k)
'    For j=1 to ccount
        Set lnk = table_object.ChildItem(k,1,"Link",0)
        txt=lnk.GetROproperty("text")
        'msgbox txt
'        If txt Then
'        End If
        If Instr(linkname,txt) > 0 Then
            stpName="Link Name Verification - "&linkname
            stpDesc=linkname&" was checked in "&module
            'report "Pass",stpName,stpDesc
            Reporter.ReportEvent micPass,stpName,stpDesc
            Flag = True
             Exit For
        End If
    'Next
    Next
    If Flag Then
        Exit For
    End If
    Browser("newScale RequestCenter").Page("newScale RequestCenter_2").Image("pageRight").Click
Next

    If Flag = False Then
        report "Fail", "Display Link", linkname & " weblink was not displayed on the page"
    End If
    
End Function
'********************************************************************************************************************************************************************************************************************
'Funcition Name : WebTable_LinkClick
'parameters: parameter one - table_object hireachry,parameter two - link name,parameter three - Number of pages to search example : 24/10 = 3 pages
'Description -  Used to Click links for Organisation Unit, People, Queues, ROles, Groups, Functional Positions on left hand side of the page
'
'*****************************************************

Function WebTable_LinkClick(table_object,linkname,pagecount,module)

'Set table_object=Browser("newScale RequestCenter").Page("newScale RequestCenter_2").WebTable("Name")
pagecount=2
For i=0 to pagecount
 rcount=table_object.RowCount
 For k=2 to rcount
    'msgbox rcount
'    ccount=Browser("newScale RequestCenter").Page("newScale RequestCenter").WebTable("Name").ColumnCount(k)
'    For j=1 to ccount
        Set lnk = table_object.ChildItem(k,1,"Link",0)
        txt=lnk.GetROProperty("text")
        'msgbox txt
        If Instr(linkname,txt) > 0 Then
            lnk.click
             stpName=" Verification of Click Link- "&linkname
            stpDesc=linkname&" was clicked in "&module
            report "Pass",stpName,stpDesc
            Flag = True
            Exit For
        End If
    'Next
    Next

    If Flag Then
        Exit For
    End If
    Browser("newScale RequestCenter").Page("newScale RequestCenter_2").Image("pageRight").Click
Next

    If Flag = False Then
        report "Fail", "Display Link", linkname & " weblink was not displayed on the page"
    End If
End Function

'*******************************************************************************************************************************

'Function Name: Select_RadioTable

'Parameter    :  Table_Name

'Description  :

'******************************************************************************************************************************
Public Function Select_RadioTable(Table_Name)

'Calling Function to enter Text in Search Text Field

Set Edit_Object = Browser("newScale RequestCenter_2").Page("newScale RequestCenter").WebEdit("scou_search_string")

Edit_Value = Table_Name

Edit_Name = "Search"

Edit_Set Edit_Object, Edit_Value

 'Calling Function To Click on Search Button

Set Button_Object = Browser("newScale RequestCenter_2").Page("newScale RequestCenter").WebButton("Search")

Button_Name = "Search"

Click_Button Button_Object

 wait(1)
  
rowcnt = Browser("newScale RequestCenter_2").Page("newScale RequestCenter").WebTable("**Resource: Select is").RowCount

For i = 2 To rowcnt
                    
                        Organizationunit_Name = Browser("newScale RequestCenter_2").Page("newScale RequestCenter").WebTable("**Resource: Select is").GetCellData(i,2)

                        'msgbox Organizationunit_Name
                      
                        If Trim(Table_Name) = Trim(Organizationunit_Name) Then
                     
            R_Value = Browser("newScale RequestCenter_2").Page("newScale RequestCenter").WebTable("**Resource: Select is").ChildItem(i, 1, "WebRadioGroup", 0).GetROproperty("value")

                                    'msgbox Radio_Value
                                 
                                    'Browser("newScale RequestCenter_2").Page("newScale RequestCenter").WebTable("**Resource: Select is").ChildItem(i, 1, "WebRadioGroup", 0).Select Radio_Value

                                    Set R_Object = Description.Create()

                                    R_Object("micclass").Value = "WebRadioGroup"


                                    Set Radio_Object = Browser("newScale RequestCenter_2").Page("newScale RequestCenter").WebTable("**Resource: Select is").WebRadioGroup(R_Object)

                                    Radio_Value = R_Value

                                    Radio_Name = "Organization Unit"

                                    Set_Radiobutton Radio_Object, Radio_Value, Radio_Name

Exit For

End If
                     
Next
                                        
'Calling Function to Click on Add Button

Set Button_Object = Browser("newScale RequestCenter_2").Page("newScale RequestCenter").WebButton("Add")

Button_Name = "Add"

Click_Button Button_Object

End FUnction

'*******************************************************************************************************************************

'Function Name: Set_Radiobutton

'Parameter    :  Object, Value     

'Author        :

'Description  :

'*******************************************************************************************************************************

Function Set_Radiobutton(Radio_Object, Radio_Value, Radio_Name)

            objectName=Radio_Name

            stepName="SetRadio Button"

            passDesc=objectName+" was Selected successfully"

            failDesc=objectName+" object was not found "

            if objectName <> "" then

                        if Radio_Object.Exist then

' replaced set

                                    Radio_Object.Select  Radio_Value

                                    Report "Pass",stepName,passDesc

                                    else

                                    Report "Fail",stepName,failDesc

                        end if

            end if

End Function

'
'Function Select_Module(mod_Name)
'    'f_log.WriteLine "INFO <Select_Module>Entering the keyword Select_Module"
'
'Select Case lcase(mod_Name)
'  Case "servicedesigner"
'      If Browser("newScale - Login").Page("newScale RequestCenter").WebElement("newScale RequestCenter").Exist Then
'          Browser("newScale - Login").Page("newScale RequestCenter").WebElement("newScale RequestCenter").Click
'          If Browser("newScale - Login").Page("newScale RequestCenter").Link("ServiceDesigner").Exist Then
'             Browser("newScale - Login").Page("newScale RequestCenter").Link("ServiceDesigner").Click
'             Reporter.ReportEvent micPass,"Select Module",mod_name&" was selected"   
'        end if     
'    else
'   
'    End If
'  Case "servicecommunity"     
'     If Browser("newScale RequestCenter").Page("newScale RequestCenter").WebElement("newScale RequestCenter").Exist Then
'         Browser("newScale RequestCenter").Page("newScale RequestCenter").WebElement("newScale RequestCenter").Click
'         If Browser("newScale RequestCenter").Page("newScale RequestCenter").Link("Service Community2").Exist Then
'            Browser("newScale RequestCenter").Page("newScale RequestCenter").Link("Service Community2").Click
'            Reporter.ReportEvent micPass,"Select Module",mod_name&" was selected"
'         End If
'    else
'       
'    End If
'Case "myservice"
'    If     Browser("newScale - Login").Page("newScale RequestCenter").WebElement("newScale RequestCenter").Exist Then
'         Browser("newScale - Login").Page("newScale RequestCenter").WebElement("newScale RequestCenter").Click
'         if Browser("newScale - Login").Page("newScale RequestCenter").Link("MyServices").Exist then
'            Browser("newScale - Login").Page("newScale RequestCenter").Link("MyServices").Click
'            Reporter.ReportEvent micPass,"Select Module",mod_name&" was selected"
'        end if    
'    else
'   
'    End If
'Case "servicemanager"
'    If        Browser("newScale - Login").Page("newScale RequestCenter").WebElement("newScale RequestCenter").Exist Then
'            Browser("newScale - Login").Page("newScale RequestCenter").WebElement("newScale RequestCenter").Click
'            If Browser("newScale - Login").Page("newScale RequestCenter").Link("ServiceManager").Exist Then
'               Browser("newScale - Login").Page("newScale RequestCenter").Link("ServiceManager").Click
'                   Reporter.ReportEvent micPass,"Select Module",mod_name&" was selected"
'            End If
'    else
'
'    End If
'    Case else
'
'End Select
'    'f_log.WriteLine "INFO <Select_Module>Exiting the keyword Select_Module"
'End Function
--------------------

'a=Browser("QA 120 - Misys Confirmation").Page("QA 120 - Misys Confirmation").WebEdit("atxtPassword")

Set xl=CreateObject("Excel.Application")
Set wb=xl.Workbooks.Open("p:\1.xls")
Set ws=wb.Worksheets("sheet1")
a=ws.cells(1,2)
b=ws.cells(2,2)
CALL enter (a, b)
wb.Application.quit
'place a in excel sheet

----------------
Function enter (byval a, byval strInput)
    c = a+".set " & strInput
    strCmd =  "runTimeValue = " + a + ".Exist(0)"
    Execute strCmd   
   msgbox c
   b = "msgbox c"
   Execute b
   Execute c
End Function

Popular posts from this blog

Online Selenium Training With Real Time Scenario

Online Tricentis Tosca Automation Training with Real Time Scenarios

Online Training for Manual/Functional