Micro Focus QTP (UFT) Forums
DIV and span tags - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: VB Scripting/Descriptive Programming (https://www.learnqtp.com/forums/Forum-VB-Scripting-Descriptive-Programming)
+--- Thread: DIV and span tags (/Thread-DIV-and-span-tags)



DIV and span tags - techvas - 06-11-2013

Hi,

Good morning.
I am new to QTP. I got the following html code snippet. How can i extract the span tag values under div and ul tags in the following formats.



HTML code:
Code:
<div id=firstheader> HEADER1value </div>
<div id = "firstheadervalues">
<ul>
<li><span class="percentage"> 7% </span> <span class="listval">column1</span></li>
<li><span class="percentage"> 8% </span> <span class="listval">column2</span></li>
<li><span class="percentage"> 9% </span> <span class="listval">column3</span></li>
<li><span class="percentage"> 10% </span> <span class="listval">column3</span></li>
</ul>
</div>


<div id=secondheader> HEADERSECOND </div>
<div id = "secondheadervalues">
<ul>
<li><span class="numval"> 123 </span> <span class="secondval">value123</span></li>
<li><span class="numval"> 124 </span> <span class="secondval">value124</span></li>
<li><span class="numval"> 125 </span> <span class="secondval">value125</span></li>
<li><span class="numval"> 126 </span> <span class="secondval">value126</span></li>
</ul>
</div>

How can i print the values in the following format????

HEADER1Value
column1 --- 7
column2 --- 8
column3 --- 9
column4 --- 10


HEADERSECOND

value123 -- 123
value124 -- 124
value125 -- 125
value126 -- 126

its urgent.Your help will be greatly appreciated.

Thanks you .
vas.


RE: DIV and span tags - techvas - 06-11-2013

Guys, can you please help some one. Thanks. More info the web page build with jquery framework.


RE: DIV and span tags - Ankur - 06-12-2013

If you're using QTP 11 or UFT 11.5, your job has become a tad easier. Use CSS object identification method.


RE: DIV and span tags - techvas - 06-12-2013

Ankur, Can you please provide me code.

Also we are using QTP 10.

Thank you,


RE: DIV and span tags - Ankur - 06-21-2013

I hope you were able to solve this, in case not here is a snippet to get percentage -

Code:
Set oPercentage = Description.Create
oPercentage("micclass").value = "WebElement"
oPercentage("class").value = "percentage"

Set oAllPercentageObjects =  Browser("Browser").Page("Page").ChildObjects(oPercentage)

'msgbox oAllPercentageObjects.Count

For r = 0 To oAllPercentageObjects.count - 1
msgbox oAllPercentageObjects(r).GetROProperty("innerhtml")    
Next



RE: DIV and span tags - benjwal - 06-20-2015

----------------------------
Dear Ankur,
You solution worked. Thank you!
I am able to go to all the span in the div and pick up values in my case how do I go further and then pick values.

Can you help me with some guidance on how to pick up the anchor values inside and anchor in a div. and a span.
code from where to capture is as below.
I wish to capture
Code:
sip="ABenjwal@uk.com"
showofflinepawn="1"

<td class="ms-vb-lastCell ms-cellstyle ms-vb-user ms-vb-lastCell"><span class="ms-verticalAlignTop ms-noWrap ms-displayInlineBlock"><span class="ms-imnSpan"><a class="ms-imnlink ms-spimn-presenceLink" onclick="IMNImageOnClick(event);return false;" href="#"><span class="ms-spimn-presenceWrapper ms-imnImg ms-spimn-imgSize-10x10"><img name="imnmark" title="" class="ms-spimn-img ms-spimn-presence-online-10x10x32" id="imn_17,type=smtp" alt="Offline" src="https://de17.eyqa.net/_layouts/15/images/spimn.png" sip="ABenjwal@uk.com" showofflinepawn="1"></span></a></span><span class="ms-noWrap ms-imnSpan"><img name="imnmark" title="" class=" ms-hide" id="imn_18,type=smtp" alt="Offline" src="https://de17.qa.net/_layouts/15/images/spimn.png" sip="ABenjwal@uk.com" showofflinepawn="1"><a tabindex="-1" class="ms-imnlink" onclick="IMNImageOnClick(event);return false;" href="#"></a><a class="ms-subtleLink" onclick="GoToLinkOrDialogNewWindow(this);return false;" href="/sites/Taxeng1/_layouts/15/userdisp.aspx?ID=24">George M. Cohan</a></span></span></td>



RE: DIV and span tags - supputuri - 06-24-2015

you can use combination of GetRoProperty and split to achieve this.
Please let me know if you need a snippet.