Forum Discussion

nakshatra's avatar
nakshatra
Contributor
5 years ago
Solved

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.

 

  • nakshatra's avatar
    nakshatra
    5 years ago

    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 :)

4 Replies

    • nakshatra's avatar
      nakshatra
      Contributor

      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's avatar
        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.