Can we get a sibling object from an object properties using DP

563 views
Skip to first unread message

iRahulSingh

unread,
May 9, 2012, 4:35:23 AM5/9/12
to QTP - HP Quick Test Professional - Automated Software Testing
Hi All,

My situation is I've to get an object from my web application which
doesn;t have any unique properties ( literally NO Unique properties )
but can be found out using another object which can be identified
uniquely.
Now my reuqirement is i can identify an object which has unique
properties so can i somehow get any handle for this object ( with no
unique properties ) which is a sibling of other object.

PS : i can;t use Visual identification to add the object as i've to
add the first object using DP only .

Any possibility guyz ??


Cheers ...

Anshoo Arora

unread,
May 9, 2012, 5:19:15 AM5/9/12
to mercu...@googlegroups.com

Its possible. You can use any of the three: Visual Relational identifiers (QTP 11 only), DOM nodes or XPath (QTP 11 only).

--
You received this message because you are subscribed to the Google
"QTP - HP Quick Test Professional - Automated Software Testing"
group.
To post to this group, send email to Mercu...@googlegroups.com
To unsubscribe from this group, send email to
MercuryQTP+...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/MercuryQTP?hl=en

iRahulSingh

unread,
May 9, 2012, 5:52:05 AM5/9/12
to QTP - HP Quick Test Professional - Automated Software Testing
Hi Anshoo,

I'm still a naive to work with XPath hence my only way-out seems to be
DOM nodes BUT how to go abt. it ....
sorry to be a cry baby but how can we go ahead. following is the
source code of the page from which i've to extract the object :


<div id="Id_983095891633" class="recomRDiv" align="left"
style="padding-top:10px;padding-bottom:3px;">
<b class="xtop">
<b class="xb1"></b>
<b class="xb2"></b>
<b class="xb3"></b>
<b class="xb4"></b>
</b>
<div class="fhresultcontenttop">
<div class="airlineinfo">
<div class="airlineicon">
<div class="airlinename">Finnair</div>
</div>
<div class="flightdetails">
<div class="legdata">
<div class="legseparator"></div>
<div class="legdata">
</div>
<div class="price">
<div class="orange-big-heading-price">
<span style="font-size:10px;color:#666666; padding-left:6px;">
<br>
<img src="../img/us/hurry-few-seats.gif">
<br>
</div>
<div class="age">&nbsp;</div>
</div>
<div style="border-left: 1px solid lightgrey; border-right: 1px solid
lightgrey;padding-bottom:10px;">
<div style="position:relative;height:29px;"> --> want to identify
this div !!
</div>
<div class="fhresultcontentbottom">
<div class="checknow1" style="padding-top:1px;">
<div class="checkFlightDetails" style="padding-top:1px;">
<div class="checkFlightDetailsPad" style="padding-top:1px;">
<div class="traveldates">
</div>
<div id="flightDetails_Id_983095891633" class="flDb" align="center"
style="clear:both;"></div>
<b class="xbottom">
<b class="xc4"></b>
<b class="xc3"></b>
<b class="xc2"></b>
<b class="xc1"></b>
</b>
</div>

On May 9, 2:19 pm, Anshoo Arora <anshooar...@gmail.com> wrote:
> Its possible. You can use any of the three: Visual Relational identifiers
> (QTP 11 only), DOM nodes or XPath (QTP 11 only).

Anshoo Arora

unread,
May 9, 2012, 6:59:00 AM5/9/12
to QTP - HP Quick Test Professional - Automated Software Testing
There are many possible ways, but have listed two quick ones below:

MsgBox Browser("").WebElement("class:=fhresultcontentbottom", "html
tag:=DIV").Object.previousSibling.outerHTML
MsgBox Browser("").WebElement("class:=price", "html
tag:=DIV").Object.nextSibling.childNodes(0).outerHTML

iRahulSingh

unread,
May 9, 2012, 1:17:56 PM5/9/12
to QTP - HP Quick Test Professional - Automated Software Testing
Thanx Anshoo, was quite unaware of this :(

must have tried myself first on your guidance that HTML DOM object
have to be used.....

Thanx agn AA !!

iRahulSingh

unread,
May 14, 2012, 5:57:48 AM5/14/12
to QTP - HP Quick Test Professional - Automated Software Testing
Hi Anshoo,
I tried and tried again but was not able to get to the object
iintended to find. I'm not sure i'f i'm following everything
correctlybut the end result is i'm not able to get hold of the div
object. I'vetried the following things :
Set ichilds
=Browser("IntFl").Page("IntFl").WebTable("RestOfPage").WebElement("AllResultsDiv").ChildObjects(iflht)For
i = 0 to ichilds.count
       Set aiodesc = Description.Create       aiodesc ("html
tag").value = "div"       aiodesc ("micclass").value = "WebElement"   
   aiodesc ("class").value = "fhresultcontentbottom"
       ichilds(i).WebElement(aiodesc ).getroproperty("innertext") ->
working !!       Set promoObj =
aDtls.Object.previousSibling.FirstChild       -> NOT working :(     
 Set promoObj = aDtls.Object.nextSibling.FirstChild       ->NOT
working :(       Set promoObj = aDtls.Object.previousSibling.LastChild
      ->NOT working :(       Set promoObj =
aDtls.Object.nextSibling.LastChild       -> NOTworking :(
error is : Object required: 'aDtls.Object.previousSibling.FirstChild'
Actually, as soon as i create a DOm object using .object and tries
touse any property / method then i'm getting the error.Hope i'm not
missing anything here ...
any information what can be done here ,....
CHeers...

Anshoo Arora

unread,
May 14, 2012, 10:17:28 AM5/14/12
to QTP - HP Quick Test Professional - Automated Software Testing
Rahul, I am not sure what you're doing wrong. The code seems a bit
unclear. In your code, you are also using OR which can make it harder
to tell exactly which DIV your code is pointing to. For example,
looking at your code below:

Set promoObj = > aDtls.Object.previousSibling.FirstChild

What is aDtls? There is no reference made to it to know which element
it points to.

However, since you're doing it using the ChildObjects approach, see
below:

Set desc = Description.Create
desc("class").Value = "fhresultcontentbottom"
desc("micclass").Value = "WebElement"

Set DIVs = Browser("").Page("micclass:=Page").ChildObjects(desc)
MsgBox DIVs(0).Object.previousSibling.outerHTML

Likewise, using the code in the previous example, you can also do the
following:

Set DIV = Browser("").WebElement("class:=fhresultcontentbottom", "html
tag:=DIV").Object
MsgBox DIV.previousSibling.outerHTML
Reply all
Reply to author
Forward
0 new messages