Read the current Iteration count from a smart folder

Ask general questions here.
[email protected]
Posts: 7
Joined: Tue Mar 27, 2018 10:29 am

Read the current Iteration count from a smart folder

Post by [email protected] » 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: 5360
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

[email protected]
Posts: 7
Joined: Tue Mar 27, 2018 10:29 am

Re: Read the current Iteration count from a smart folder

Post by [email protected] » 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: 5360
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

[email protected]
Posts: 7
Joined: Tue Mar 27, 2018 10:29 am

Re: Read the current Iteration count from a smart folder

Post by [email protected] » 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
Attachments
Ranorex Smartfolder Iteration.jpg
Ranorex Smartfolder Iteration.jpg (19.01 KiB) Viewed 43 times

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5360
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

[email protected]
Posts: 7
Joined: Tue Mar 27, 2018 10:29 am

Re: Read the current Iteration count from a smart folder

Post by [email protected] » Wed Nov 20, 2019 11:42 am

The code is placed in the "LoginWithLogging" recording.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 5360
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