Search This Blog

Friday, September 9, 2011

QTP & QC : Code to enter or select data in webedit, weblist, webcheckbox if not null

'**********************************************************************************************************
'Function Name:   WebEdit_SetIfNotNull(strValue)
'Description :        Used to set the Parameter value if it is not NULL
'Parameters:        strValue
'Return  value       NA
'Example:              WebEdit_SetIfNotNull Parameter("Name")
'**********************************************************************************************************
Function WebEdit_SetIfNotNull(test_object , strValue )
 If Trim(strValue) <> "" Then
  If test_object.Exist(5) Then
   If test_object.GetROProperty("disabled") = 0 Then
    test_object.Set strValue
   End If
  End If
 End If
End Function
RegisterUserFunc "WebEdit", "SetIfNotNull", "WebEdit_SetIfNotNull"

'**********************************************************************************************************
'Function Name:   WebCheckBox_SetIfNotNull(strValue)
'Description :        Used to set the Parameter value if it is not NULL
'Parameters:        strValue
'Return  value       NA
'Registerd To      WebCheckBox
'Example:              WebCheckBox_SetIfNotNull Parameter("Name")
'**********************************************************************************************************
Function WebCheckBox_SetIfNotNull(test_object , strValue )
 If Trim(strValue) <> "" Then
  If test_object.Exist(5) Then
   If test_object.GetROProperty("disabled") = 0 Then
    test_object.Set strValue
   End If
  End If
 End If
End Function
RegisterUserFunc "WebCheckBox", "SetIfNotNull", "WebCheckBox_SetIfNotNull"

'**********************************************************************************************************
'Function Name:   WebList_SelectIfNotNull(strValue)
'Description :        Used to set the Parameter value if it is not NULL
'Parameters:        strValue
'Return  value       NA
'Registerd To      WebList
'Example:              WebList_SelectIfNotNull Parameter("Name")
'**********************************************************************************************************
Function WebList_SelectIfNotNull(test_object , strValue )
 If Trim(strValue) <> "" Then
  If test_object.Exist(5) Then
   If test_object.GetROProperty("disabled") = 0 Then
    test_object.Select strValue
   End If
  End If
 End If
End Function
RegisterUserFunc "WebList", "SelectIfNotNull", "WebList_SelectIfNotNull"

Example code:-

Browser("Browser Main").Page("Allocation Review").WebList("levelList").SelectIfNotNull "Color"
Browser("Browser Main").Page("Allocation Review").WebEdit("levelList").SetIfNotNull "Color"
Browser("Browser Main").Page("Allocation Review").WebCheckbox("levelList").SetIfNotNull "ON"

No comments:

Post a Comment