I know that you have come on this page because you are testing the web application.
Web application testing is very interesting stuff.
Apart from normal web methods and properties provided by QTP, you can use lot of native methods of the web elements.
One of such native method of the document object is getElementById.
This method takes one parameter as an input which should be the id of the element.
Example.
<body>
<div id="head">
This text is inside div element of which id is - head
</div>
</body>
In above example, we have sample html document body in which there is one div element with id = 'head' and it contains some text.
To get the value inside this div element, we can use the innertext method as mentioned below.
print Browser("myb").Page("myp").object.getElementById("head").innerText
So output of above code will be.
"This text is inside div element of which id is - head"
Thus basically we use getElementById method to get the element object and then we can use its innerText method to get the data inside that element.
Please note that we can also get the data inside hidden elements using this method. QTP can not read data inside hidden elements.
You can find all concepts on QTP (UFT) on Master Page.
This is how we can use html dom in qtp to get the information displayed on the webpage. This makes the web application testing quite easy stuff.
Web application testing is very interesting stuff.
Apart from normal web methods and properties provided by QTP, you can use lot of native methods of the web elements.
One of such native method of the document object is getElementById.
This method takes one parameter as an input which should be the id of the element.
Example.
<body>
<div id="head">
This text is inside div element of which id is - head
</div>
</body>
In above example, we have sample html document body in which there is one div element with id = 'head' and it contains some text.
To get the value inside this div element, we can use the innertext method as mentioned below.
print Browser("myb").Page("myp").object.getElementById("head").innerText
So output of above code will be.
"This text is inside div element of which id is - head"
Thus basically we use getElementById method to get the element object and then we can use its innerText method to get the data inside that element.
Please note that we can also get the data inside hidden elements using this method. QTP can not read data inside hidden elements.
You can find all concepts on QTP (UFT) on Master Page.
This is how we can use html dom in qtp to get the information displayed on the webpage. This makes the web application testing quite easy stuff.
- 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
No comments:
Post a Comment
Please Leave your reply. We value your feedback and inputs