Ask a Question

Exploring the Dom - Finding ChildNodes (Discussion Two)

New Contributor

Exploring the Dom - Finding ChildNodes (Discussion Two)

I am unable to retrieve any child elements within a table. When using the following code, I am able to retrieve the entire row with no issue:


1. var xpath = "//tr/td/div[text() = 'Ryan STIG Regression Test']"; 
2. var theVisitor = page.FindChildByXPath(xpath)
4. if(theVisitor.Exists){
6. Sys.HighlightObject(theVisitor);
7. Log.Message(theVisitor.parentElement.parentElement.innerText); 

But when adding the following code :

8. Log.Message(theVisitor.parentElement.parentElement.cells[1].innerText);

I receive a JavaScript runtime error. “TypeError: Cannot read property ‘innerText’ of undefined.

This is a valid element search, as it works with no problem when utilizing the browser console via the dev tools

Why am I not able to retrieve the child elements in TestComplete but I am in the browser console? Any help would be very much appreciated! Thanks in advance.



Esteemed Contributor

TestComplete identifes objects differently.  It reads the DOM to do so but then identifies objects based pon properties of the object.  If parentElement is not recognized as a table, it won't have a "cells" property according to TestComplete so even the "cells" call won't work.


If you're going to have the greatest success with TEstComplete, I'd move away from using XPath as your prirmary means of identiification.  Look up the OBject browser and NameMApping in the documentation and start working from there in identifying objects.

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

Thank you for the insight

Showing results for 
Search instead for 
Did you mean: