Ask a Question

How to retrieve values from HTML Table using DOM

Mathit
Contributor

How to retrieve values from HTML Table using DOM

I have a table as attached and I want to retrieve values of columns using DOM.  

Please suggest

14 REPLIES 14
tristaanogre
Community Hero

Re: How to retrieve values from HTML Table using DOM

If you use the Object Spy tool in TestComplete (https://support.smartbear.com/testcomplete/docs/testing-with/exploring-apps/object-spy/about.html) how do the fields show up there?

What is the reason for using DOM to find the values? Is this a specific requirement for your test case?

have you looked into using a Table checkpoint or an Web Comparison checkpoint?  


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Mathit
Contributor

Re: How to retrieve values from HTML Table using DOM

When i do a spy, it shows as a table that takes much longer to retrieve the column valuesfor some reason.

 

Aliases.browser.Page("*").Panel(0).Panel(0).Panel(0).Section("content").Panel(1).Panel("applicantForm").Panel(0).Form("Application").Panel(0).Panel(0).Panel(5).Panel(0).Panel(0).Panel(1).Panel("coverageSummary").Panel(0).Panel(1).Table("pdTable")

tristaanogre
Community Hero

Re: How to retrieve values from HTML Table using DOM

It shouldn't take that long.  TestComplete reads the DOM and translates it into objects.

Based upon the Alias you have presented, there are alot of components, including the page, that are not included in any sort of mapping..  Generally, once you obtain the table, you then can retrieve the contents of the cells by referencing the cell by row and column index.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
boimdijogja
New Member

Re: How to retrieve values from HTML Table using DOM

I need this information

tristaanogre
Community Hero

Re: How to retrieve values from HTML Table using DOM

Additional note...  when using NameMapping and Aliases, in the Alias part of the editor, you can exclude the unnecessary Panel objects.  

Please read up on https://support.smartbear.com/testcomplete/docs/testing-with/object-identification/name-mapping/abou... as this will help you in identifying your objects.  From there, once you have the table mapped, you should be able to reference individual cells by row and column index and retrieve the contents from the cell.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Mathit
Contributor

Re: How to retrieve values from HTML Table using DOM

Thank you for your response.

I dont use Namemapping, could that be the reason it takes much longer to capture values on the grid?

sometimes, UI itself takes longer to load and then reading all the values.  So will it reduce the time taken if I grab values using DOM?

Thanks again,

tristaanogre
Community Hero

Re: How to retrieve values from HTML Table using DOM

I think you'll see some improvement, to be honest.  TestComplete is built and structured around NameMapping and object identification. 

Also, your page object is generic... Page('*')... so, if you have more than one page open, it needs to find which page you're working off of that matches...   So, really, it all comes down to proper object identification.

You still haven't answered the question: Why do you want to use DOM?  Is this some requirement?


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
Mathit
Contributor

Re: How to retrieve values from HTML Table using DOM

In my test, i only open one page, and the url keeps changing so i have given Page(*).

No specific reason to use DOM.  Only because the objects on the page takes a bit longer to load, in spinning view for few seconds until all the grids are visible and then it takes a bit longer to go through each grid on the page, hence was exploring options to grab from DOM

tristaanogre
Community Hero

Re: How to retrieve values from HTML Table using DOM

You still won't be able to interact with the object until it's fully loaded, even if you go via DOM.  The problem is not with TC, it's simply the nature of things.

As for your dynamic URL... you can use wildcards in the URl.  Say there's an ID that keeps changing.  You could use Page('http://myapp.me.com/app/*') This is preferable to a fully dynamic page.


Robert Martin
[Hall of Fame]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Vegas Thrill Rider
Extensions available
cancel
Showing results for 
Search instead for 
Did you mean: