Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Check existence of web objects on page
#1
Solved: 11 Years, 3 Months, 4 Weeks ago
I have 10 Webedit and 2 Weblist fields in the web application page. I need QTP to

(a) Validate their existence on the page and if yes, check if they are greyed out (disabled)
(b) Compare the values against a global datasheet

Could you please help me write a generic function which can be used to do (a) and (b) for different web objects like WebEdit, WebList, Radiobutton etc?

Thanks a ton!
Liju
Reply
#2
Solved: 11 Years, 3 Months, 4 Weeks ago
Would you paste the code you have tried so far? Would be easier to correct it.
Furthermore, you dont have to consider how many webedits and weblists are on the webpage. You can make it very generic, such as, you pass the object and it should check for the conditions you have.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#3
Solved: 11 Years, 3 Months, 4 Weeks ago
I'm sure there's lots wrong in here Tongue This code doesnt seem to work at all for me. QTP shows Runtime error - what am I doing wrong here? Please help.

Object doesnt support this property or method: ExistsAndDisabled Browser("IPSDK WEB GUI (Search)").Page("Customer Info").Frame("Quote Header").Table("Quote_Header_Table").WebEdit("Quote_RefId")

My code for one webedit field :
------------------------------

Code:
Dim QuoteName
Set QuoteName = Browser("IPSDK WEB GUI (Search)").Page("Customer Info").Frame("Quote Header").Table("Quote_Header_Table").WebEdit("Quote_Name")
    If ExistsAndDisabled(QuoteName) Then
        Reporter.ReportEvent micPass, "Checking Object Status", QuoteName.GetTOProperty("html id") & " was found and disabled."
   Else
        Reporter.ReportEvent micFail, "Checking Object Status", QuoteName.GetTOProperty("html id") & " was either not found or disabled."
Quote_Name=QuoteName.GetROproperty("value")
Quote_Name_value = DataTable.Value("Quote_Name", GLOBAL)
CheckValue Quote_Name, Quote_Name_value
End If

Public Function ExistsAndDisabled(test_object)
ExistsAndEnabled=True
If  test_object.Exist() Then
  If test_object.GetROProperty("enabled")=1 Then
    ExistsAndEnabled=False
  End If
  Else
    ExistsAndEnabled=True
End If    
End Function

Public Function CheckValue(str1, str2)
     If strcomp (str1, str2) =0 Then
        Reporter.ReportEvent micPass, "Checking object value", str1 & "was found"
     End If
End Function
Reply
#4
Solved: 11 Years, 3 Months, 4 Weeks ago
See if this works,

Code:
Dim QuoteName
Set QuoteName = Browser("IPSDK WEB GUI (Search)").Page("Customer Info").Frame("Quote Header").Table("Quote_Header_Table").WebEdit("Quote_Name")

If ExistsAndDisabled(QuoteName) Then

Reporter.ReportEvent micPass, "Checking Object Status", QuoteName.GetTOProperty("html id") & " was found and disabled."
Else

Reporter.ReportEvent micFail, "Checking Object Status", QuoteName.GetTOProperty("html id") & " was either not found or disabled."
Quote_Name=QuoteName.GetROproperty("value")
Quote_Name_value = DataTable.Value("Quote_Name", GLOBAL)
CheckValue Quote_Name, Quote_Name_value
End If

Public Function ExistsAndDisabled(test_object)
ExistsAndDisabled=True
If test_object.Exist Then
If test_object.GetROProperty("enabled")= "True" Then
ExistsAndDisabled=False
End If
Else
ExistsAndDisabled=True
End If
End Function

Public Function CheckValue(str1, str2)
If strcomp (str1, str2) =0 Then
Reporter.ReportEvent micPass, "Checking object value", str1 & "was found"
End If
End Function
Honestly, i dont have the time to refine your function, however the above should work for your tweaked purpose. I will try and work on it during my free time, however no promises Smile
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply
#5
Solved: 11 Years, 3 Months, 4 Weeks ago
I was able to resolve this as soon as I made changes to the syntax:

Code:
Set QuoteRefId = Browser("IPSDK WEB GUI (Search)").Page("Customer Info").Frame("Quote Header").WebEdit("Quote_RefId")

Earlier, the Webedit was shown under a Webtable, hence QTP was not supporting it.

Without manually calling the function ExistsandDisabled for each web object like Webedit, Weblist etc, is it possible to write a function which would do ExistsandDisabled() functions for all webobjects on the shown page? Right now, I have to write separate code for 10-12 webobjects on the page Sad
Reply
#6
Solved: 11 Years, 3 Months, 4 Weeks ago
Its called registeruserfunc. You can register userdfined function against objects. Search and learn about it.
Basanth
Give a fish to a man and you feed him for a day..Teach a man how to fish and you feed him for life.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Smile If Then Is Always True For Web Objects zunebuggy 1 932 04-17-2020, 04:30 AM
Last Post: zunebuggy
  click each web link in a page using Index or other method in QTP smeijer 13 24,674 04-29-2017, 04:53 PM
Last Post: kowshik
  VB Script to count number of links in a web page. Suma Parimal 4 25,257 07-01-2015, 12:59 PM
Last Post: govind
  How to connect two web element objects? zawarepradeep@gmail.com 1 2,638 07-23-2014, 11:23 PM
Last Post: Ankur
  Spy is not deteting Web objects ssandula 0 1,910 11-25-2013, 04:33 PM
Last Post: ssandula

Forum Jump:


Users browsing this thread: 2 Guest(s)