Ask a Question

Table not found error is getting displayed

SOLVED
nakshatra
Contributor

Table not found error is getting displayed

Hi All,

 

I am trying to get row values from table.

 

here is my javascrpit code:

Browsers.Item(btChrome).Navigate("url");
Aliases.browser.pageTestCmAccesshealthcarephysic.form.panel.fieldset.textboxUserid.SetText("Username");
Aliases.browser.pageTestCmAccesshealthcarephysic.form.panel.fieldset.passwordboxPassword.SetText("Password");
Aliases.browser.pageTestCmAccesshealthcarephysic.form.panel.fieldset.buttonSubmit.ClickButton();
Aliases.browser.pageTestCmAccesshealthcarephysic2.Wait();
Aliases.browser.pageTestCmAccesshealthcarephysic2.formSearchmemberform.fieldset.textboxMemberidinput.SetText("12");
Aliases.browser.pageTestCmAccesshealthcarephysic2.formSearchmemberform.fieldset.buttonSearchmembersbutton.ClickButton();
let table = Aliases.browser.pageTestCmAccesshealthcarephysic2.formSearchmemberform.FindChild("id", "SearchResultGrid", 10);
if (table.Exists)
{
// Goes through the rows and cells of the table
for (var i = 0; i < table.rows.length; i++)
{
Log.AppendFolder("Row " + i);
for (var j = 0; j < table.rows.item(i).cells.length; j++)
Log.Message("Cell " + j + ": " + table.rows.item(i).cells.item(j).innerText);
Log.PopLogFolder();
}
}
else
Log.Warning("The table was not found");

 

I am getting table not found error. 

Could you please anyone can explain what is the mistake?

 

And how to find Test obj For find child.(TestObj.FindChild(PropNamesPropValuesDepthRefresh))

I attached My name mapping file. Highlighted object is my table grid.

 

Thanks In Advance.

 

4 REPLIES 4
tristaanogre
Esteemed Contributor

If the table is not found... then the table is not found.  Your find child code is not finding the table and returning a stub object where the "Exists" property is "false". 

 

Since the table is mapped already, instead of using "FindChild", try using "WaitAliasChild"

 

https://support.smartbear.com/testcomplete/docs/reference/test-objects/members/common-for-all/waital...


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

Thanks for the reply.

 

Can you please explain me by using my name mapping file how to use WaitAliasChild.

Actually I am getting confusion what i have to mention in TestObj and childname.

 

 

tristaanogre
Esteemed Contributor

Here's the code you have

 

let table = Aliases.browser.pageTestCmAccesshealthcarephysic2.formSearchmemberform.FindChild("id", "SearchResultGrid", 10);

Here's what the new code would be

 

let table = Aliases.browser.pageTestCmAccesshealthcarephysic2.formSearchmemberform.WaitAliasChild('tableSearchresultgrid', 10000);

What this will do is wait for the object that you already have mapped (tableSearchresultgrid) for a maximum of 10 seconds.  You can increase this value as much as necessary.  The object will return as soon as it is avalable or when the maximum timeout elapses.

Probably what is happening in your original code is a timing issue that, when you go to Find the object, it's not there yet.  You click a button and then look for the table... I'm guessing there's a delay.  So, WaitAliasChild covers the search for the object AND waiting for it to be present.


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

Thanks for the reply.

 

New code throwing error. 

 

Correct code is :

let table= Aliases.browser.pageTestCmAccesshealthcarephysic2.WaitAliasChild('tableSearchresultgrid', 10000);

 

tableSearchresultgrid is child of pageTestCmAccesshealthcarephysic2. With this code it's working.

Thanks 🙂

cancel
Showing results for 
Search instead for 
Did you mean: