Read the current Iteration count from a smart folder

Ask general questions here.
Peter@Vecscan
Posts: 7
Joined: Tue Mar 27, 2018 10:29 am

Read the current Iteration count from a smart folder

Post by Peter@Vecscan » Wed Nov 20, 2019 10:39 am

Hi,

Got several test cases with a iteration of 3 set inside smart folders. Now I would like to enhance some features of this suite but then I need to read the current value of the iteration. Whatever I do I seem only to be able to get the value from the test case, that is always 1. How can I read the current iteration of a smart folder?

BR // Peter S

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

Re: Read the current Iteration count from a smart folder

Post by odklizec » Wed Nov 20, 2019 10:57 am

Hi,

You can use this, in case you are using data connector in given smart folder:

Code: Select all

int currentIterationIndex = TestSuite.Current.GetTestContainer(TestSuite.CurrentTestContainer.Name).DataContext.CurrentRowIndex;
or this, in case the smart folder is using simple "iteration" counter (no attached data connector):

Code: Select all

int currentIterationIndex = Ranorex.Core.Reporting.TestReport.CurrentTestIterationActivity.Index; 
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

Peter@Vecscan
Posts: 7
Joined: Tue Mar 27, 2018 10:29 am

Re: Read the current Iteration count from a smart folder

Post by Peter@Vecscan » Wed Nov 20, 2019 11:14 am

Hi,

No, I have tried all these but I still only get the result 1. I have assumed it was from the TestCase instead of the smart folder. Anyway, I does not work for a smart folder.

BR // PS

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

Re: Read the current Iteration count from a smart folder

Post by odklizec » Wed Nov 20, 2019 11:19 am

Hi,

Could you please share your test suite (or create and share a small sample test suite)? From where do you call the code and which one of the two I posted? Is there a data connector in the smart folder?
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

Peter@Vecscan
Posts: 7
Joined: Tue Mar 27, 2018 10:29 am

Re: Read the current Iteration count from a smart folder

Post by Peter@Vecscan » Wed Nov 20, 2019 11:30 am

Hi,

here's the code (in VB.net). Attched a screenshot of the TestSuite hierarchy.

Public Sub TcDescToNoteIfIteration1()
Dim itrname, containerName As String
Dim SmartFolderName As TestSuiteEntryContainer
SmartFolderName = TestSuite.CurrentTestContainer 'dirty one - just to check what node I looking into
'itrname = TestSuite.Current.GetTestContainer(TestSuite.CurrentTestContainer.Name.ToString()).DataContext.CurrentRowIndex.ToString()
containerName=SmartFolderName.Name.ToString()
itrname = TestSuite.Current.CurrentTestContainer.DataContext.CurrentRowIndex.ToString()
'itrname=Ranorex.Core.Reporting.TestReport.CurrentTestIterationActivity.Index
'debug
Note=TCDesc & " debug: " & itrname & " - name of test container: " & containerName 'itrname is always 1 whatever I do

End Sub
You do not have the required permissions to view the files attached to this post.

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

Re: Read the current Iteration count from a smart folder

Post by odklizec » Wed Nov 20, 2019 11:38 am

Hi,

And the code is placed where? In either of the recordings in given smart folder?
Last edited by odklizec on Wed Nov 20, 2019 11:45 am, edited 2 times in total.
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

Peter@Vecscan
Posts: 7
Joined: Tue Mar 27, 2018 10:29 am

Re: Read the current Iteration count from a smart folder

Post by Peter@Vecscan » Wed Nov 20, 2019 11:42 am

The code is placed in the "LoginWithLogging" recording.

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

Re: Read the current Iteration count from a smart folder

Post by odklizec » Wed Nov 20, 2019 11:46 am

Well, I'm not sure if CurrentTestIterationActivity is still supported as it's an internal API method ;)

The other method, should definitely return actual data connector row index? But I'm not sure how does htis work together with defined SF Iteration count?

Anyway, another solution is described in this post:
https://www.ranorex.com/forum/viewtopic ... 79&#p47879
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

Isaac
Posts: 18
Joined: Sun Feb 02, 2020 5:11 am
Location: South Africa
Contact:

Re: Read the current Iteration count from a smart folder

Post by Isaac » Thu Nov 11, 2021 5:48 pm

how to change or set count iteration of a particular Smartfolder using a code.

Let's say the Smartfolder Count iteration was 4 and now you want to change it to value 1.

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

Re: Read the current Iteration count from a smart folder

Post by odklizec » Fri Nov 12, 2021 9:28 am

Hi,

I'm afraid, there is no public API for setting the Iteration Count from code. The only thing you can probably do, is to setup the data connector in given smart folder and then change its content via code. Check this post where you can find an example code how to change content of data connector in runtime. All you have to do is to add some lines to the data connector of your choice, which means the smartfolder with associated data connector will repeat as many times as you want...
repeat-a-group-of-recordings-for-a-dyna ... 18667.html
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