Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Description.Create with same propertie and different values, not working
#1
Solved: 10 Years, 8 Months, 4 Weeks ago
Hello,
I want to count the number of WebElements with the propertie "innertext" and the values "Blue Skies Airlines 360" AND "Blue Skies Airlines 361". On my AUT there are two of these objects on my page.

This is my QTP code:
----------------------------------------------------------------------
Code:
Set flight=Description.Create()
flight("micclass").value="WebElement"
flight("innertext").value="Blue Skies Airlines 360"
flight("innertext").value="Blue Skies Airlines 361"
flight("html tag").value="B"

set nflights = Browser("name").Page("title").ChildObjects(flight)
msgbox "Number of flights: " &nflights.Count
----------------------------------------------------------------------

I run with the "Run one iteration only" option.

The number of flights QTP returns is 1 and not the expected 2.
What i am doing wrong?
(i think i have to build in a loop, but i cannot get it ok)
Reply
#2
Solved: 10 Years, 8 Months, 4 Weeks ago
because it considered the recent 'innertext' value i.e 'Blue Skies Airlines 361' which is only 1 on the screen , in this case you have to use the regular expression , while taking count of the object you have to use the properties which are sufficient to identify the similar types of objects.

Try the below code, I think this will return 2 for you:

Code:
Set flight=Description.Create()
flight("micclass").value="WebElement"
flight("innertext").value="Blue Skies Airlines.*"   '/To identify the objects of similar kind
flight("html tag").value="B"

set nflights = Browser("name").Page("title").ChildObjects(flight)
msgbox "Number of flights: " &nflights.Count


Thanks,
Harish SHenoy
Reply
#3
Solved: 10 Years, 8 Months, 4 Weeks ago
Harish thank you very much for your answer!
I just started with QTP (and with programming) and did not realise that the most recent value, in this situation, is the value QTP is working with. That is a good learning lesson for me. I will try it with regular expression.
(my english is sometimes not 100% good, because i live in Holland)
Thanks!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Trying to create List box in excel sheet at Run time with values yes No JACKSPARROW 0 1,590 01-17-2017, 11:05 AM
Last Post: JACKSPARROW
  How to find out the object property in the Description language . njnirmal 9 6,261 05-19-2015, 12:30 AM
Last Post: qtptester66523
  Error while creating object using description.create object in VB script SarodeGirish 5 5,806 06-19-2012, 05:30 PM
Last Post: ssvali
  Problem while adding description of an object using a varibale shibinp 2 3,262 08-25-2011, 10:51 AM
Last Post: shibinp
  descriptive programming- object description vnicey 3 4,366 11-24-2010, 01:02 AM
Last Post: Anu123

Forum Jump:


Users browsing this thread: 1 Guest(s)