Well - let me tell you that all the properties (previousSibling, nextSibling ) are not defined by QTP.
All these properties are HTML DOM properties that help us get the elements at the same level of the given element in web page.
You can access these method in QTP using .object property which lets you access native methods and properties of the objects/elements.
Example -
<body>
<div id="parentdiv">
This text is inside div element of which id is - parentdiv
<div id="fc">
This is nested div1
</div>
<div id="sc">
This is nested div2.
</div>
</div>
</body>
As you can see in above example, 2 div elements ( fc, sc) are inside the div(parentdiv).
So for fc-div and sc-div, parentdiv is the parent element. While for parentdiv, fc-div and sc-div are child div elements. The div elements fc-div and sc-div are siblings of each other as both are at same level.
sc-div is the nextSibling of the fc-div. While fc-div is the previousSibling of the sc-div.
You can get access to these elements using HTML DOM properties nextSibling, previousSibling properties
For example -
'access the next sibling of fc-div
set obj= Browser("myb").Page("myp").object.getElementById("fc")
print obj.nextSibling.innerText
'access the previous Sibling of sc-div
set obj= Browser("myb").Page("myp").object.getElementById("sc")
print obj.previousSibling.innerText
This is how we can access the elements using previousSibling, nextSibling in QTP.
You may find below links very useful
- http://qtp-interview-questions.blogspot.in/2013/06/how-to-use-html-dom-in-qtp.html
- http://qtp-interview-questions.blogspot.in/2013/10/what-is-previoussibling-nextsibling-in.html
- http://qtp-interview-questions.blogspot.in/2013/10/what-is-parentnode-childnodes.html
- http://qtp-interview-questions.blogspot.in/2013/10/what-is-getelementsbytagname-in-qtp.html
- http://qtp-interview-questions.blogspot.in/2013/10/how-to-use-getelementbyid-in-qtp.html
- http://qtp-interview-questions.blogspot.in/2013/10/how-to-get-innertext-of-webelement-in.html
Please give your inputs, suggestions, feedback to Us about above QTP topic. We value your thoughts.
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs