I'm going to show 4 approaches how to get lists of UI controls and process them
(for example get their count).
As an example, I will work with links on Google Labs page. My goal is to get the
list of links and count them.
I've added Google Labs page to my Object Repository and now it looks like:
There is one problem. Web page contains HTML code, which looks like
XML code but actually it is not.
For example:
o HTML code can contain unclosed img or br tags, XML code
cannot.
o HTML code is a case-insensitive markup language, XML is a case-
sensitive markup language, etc
More details here.
So, we have to convert HTML source code into XML. The converted code
is named as XHTML.
You can convert HTML documents into XHTML using an Open Source
HTML Tidy utility.
You can find more info about how to convert HTML code into XHTML
code here.
I will use the final QTP script from this page, a bit modified:
Note: you can download tidy.exe here for above QTP script.
5. Bonus approah
Why don't you count all Wen page objects manually? :) Open a source
code of the page and start counting :)
Just joking :)
Summary: