Micro Focus QTP (UFT) Forums

Full Version: How to prove if an object exists?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,

i've had allready two ideas which didn't work yet.
I use QTP 9.2.

My problem:
I want to find at least one object with "innertext:="&Kriterium on a page. So i defined an object and use the following code to prove it. Unfortuneatly the Exist-function doesn't work in this context.

My code first try:
Code:
' define object
Set chKriterium = Description.Create
chKriterium("micclass").Value = "WebElement"
chKriterium("innertext").Value = Kriterium

Browser("P@W Report Viewer").Page("P@W Report Viewer").Frame("Report").ChildObjects(chKriterium).Exist

My code second try:
Code:
' define object
Set chKriterium = Description.Create
chKriterium("micclass").Value = "WebElement"
chKriterium("innertext").Value = Kriterium

Set EditCollection = Browser("P@W Report Viewer").Page("P@W Report Viewer").Frame("Report").ChildObjects(chKriterium)

If  EditCollection.Count > 0 Then
...

Someone can me explain, why it doesn't work and maybe how to solve my problem? Would be great Smile

lucster
If Kriterium is not a variable,you missed quotes on Kriterium

Code:
chKriterium("innertext").Value = "Kriterium"

Otherwise code is fine
Thought so as well but QTP throws a "Generall Error" in the "EditCollection"-line.

This line works:
Code:
If  Browser("P@W Report Viewer").Page("P@W Report Viewer").Frame("Report").WebElement("index:=0", "innertext:="&Kriterium).Exist(10) Then
...
in that case it should work with dynamic DP as well if you add another property "index" and that timeout of 10 seconds