Get Current Test Iteration Variable Value in String()

Class library usage, coding and language questions.
maamer
Posts: 23
Joined: Fri Nov 30, 2018 6:03 pm

Get Current Test Iteration Variable Value in String()

Post by maamer » Fri Jan 25, 2019 6:17 pm

Hello all,

i have a recording 'Recording1' with test variable 'var1' inside a smart folder 'testfolder' with simple data table of one column and 3 rows binded to 'var1'. my recording is running 3 times now - clicking on 'Next' button . how ever when it comes to 3 rd iteration i want to do something else . click on delete button instead of next button. i wrote a user code method to get the value of the iteration and click on delete button if iteration value = 3rd column value. i am getting an error " object reference not set to instance of the object".

in my user code the error is at line

string itrname = TestSuite.Current.GetTestContainer(TestSuite.CurrentTestContainer.Name.ToString()).DataContext.CurrentRow.Values.ToString();

please help on how to get the current data row value.

Thank you.

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

Re: Get Current Test Iteration Variable Value in String()

Post by odklizec » Fri Jan 25, 2019 8:10 pm

Hi,

Try this code instead...

Code: Select all

string itrname = TestSuite.Current.GetTestContainer(TestSuite.CurrentTestContainer.Name).DataContext.CurrentRowIndex.ToString();
This code should return actual iteration number.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

maamer
Posts: 23
Joined: Fri Nov 30, 2018 6:03 pm

Re: Get Current Test Iteration Variable Value in String()

Post by maamer » Fri Jan 25, 2019 9:57 pm

Thank you sir, it is working i am also able to get the row data value now from this.

TestSuite.Current.GetTestContainer(TestSuite.CurrentTestContainer.Name).DataContext.CurrentRow.Values.GetValue(0).ToString()