Pass Module Global variable contents between test cases

Ask general questions here.
Posts: 1
Joined: Mon Aug 21, 2017 7:13 pm

Pass Module Global variable contents between test cases

Post by Auto_king77 » Mon Aug 21, 2017 8:27 pm

Hi. I have searched the Ranorex forums but I can not find anybody trying to do the same thing as myself. I have a recording module that performs some mouse clicks on an application. These clicks click on a ‘View System Log’ button, then export the contents of the system log to .csv, then in the same recording module I have some user code that opens up the exported .csv and iterates through each row and searches for any errors. I have tested this recording module and it works fine when run independently. The issue is that I want to reuse this recording module numerous times within different module test cases. Which would seem fine to me. See screen shot below. Recording module is called ‘Smoke_Test_CheckSystemLog’:-
1.png (37.18 KiB) Viewed 889 times
The problem is that when I open the newly exported system log .csv each time I want my code to start reading from the last row checked when the system log was previously exported i.e. not right from the start (first row) of the exported system log .csv.
What I have tried:-
I have created a global module variable (see global module variable highlighted in yellow below):-
2.png (97.24 KiB) Viewed 889 times
I then pass this global module variable to the User_Code – ‘Check_System_Log_For_Errors‘ method as a parameter. Below is the code for this method:-

Code: Select all

        public void Check_System_log_For_Errors(string columnEventTypeLetter, string columnErrorMessageLetter, string startRow)
			string systemLogName = this.FileName;
			int newStartRow;
			int startRowConverted = Int32.Parse(startRow);

			newStartRow = common_code.Check_System_log_For_Errors(columnEventTypeLetter, columnErrorMessageLetter, startRowConverted, systemLogName);

			_startRow = newStartRow.ToString();
I then created a test case global parameter (called paTest) for each my test cass (TestCase1 and TestCase2):-
4.png (70.45 KiB) Viewed 889 times
The problem is that as soon as I add this global parameter to each of my test cases when the test cases run my code will not start at the correct row, infact when the system log .csv file is opened, my code does not select a row at all and it never iterates through any rows. If I remove this global parameter, though my code functions ok i.e. it iterates through each row, but when the second test case is run it starts again from row 1 (and not starting at the last row of the previous run test).

Hope somebody can help please :D

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

Re: Pass Module Global variable contents between test cases

Post by odklizec » Tue Aug 22, 2017 10:37 am


Without seeing the test suite, it's hard to tell what's wrong. But looking at your first image, there seems to be unbound variable in second test case? Which means the variable in that second test case is not filled from Global parameter! This is why it most probably fails in second test case.
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