Lỗi trên smart index was out of range

AND THE CODE IS WORKING VERY FINE if I am clicking only one for the entire test execution i.e. PCards[1].FindDescendants[][0].PerformClick[]; and PCards[2].FindDescendants[][0].PerformClick[]; are working fine If I execute a single statement for whole test run, but if Im continuing one by one in single execution Im getting that error.

Any help will be appreciated. Thanks in advance.

odklizec Ranorex Guru Posts: 7470 Joined: Mon Aug 13, 2012 9:54 am Location: Zilina, Slovakia

by odklizec » Thu Apr 25, 2019 12:06 pm

Hi,

Could you please post a Ranorex snapshot [NOT screenshot], which would show us the structure of UI you are working with?

At next, I see a problem in bolded part of the code: ... IList PCards = dt.Find["//div[@class='portfolios__portfolio-card']"]; //getting 3 Devs here ... PCards.FindDescendants[][0].PerformClick[]; Since the PCards is a list, FindDescendants may not return expected elements? But it's hard to say without seeing the snapshot. I would suggest to try this code instead:

Code:

      var objEle = Object_Repository.Portfolios.Instance.XYz.Portfolios.test;
      DivTag dt = [DivTag]objEle;
      IList PCards = dt.Find["//div[@class='portfolios__portfolio-card']"]; //getting 3 Devs here without any issue.
      foreach [DivTag pCard in PCards] 
      {
        pCard.FindDescendans[][0].PerformClick[];
        Delay.Seconds[5];
        repo.XYz.Menu_Items.Portfolios.Click[];//I am getting back to main menu to select another A[link]
      }

Hope this helps?

Pavel Kudrys Ranorex explorer at Descartes Systems

Please add these details to your questions:

  • Ranorex Snapshot. Learn how to create one >here

Chủ Đề