Creating and accessing Lists
Posted: Fri Aug 04, 2017 1:49 pm
Hello,
I'm on Windows 10 Enterprise and using Ranorex Studio 7.1.0
I have a simple website with 4 combo boxes containing 4 items each which have a different value attribute each. When you choose 4 items, the added total (the 'price') is displayed below the boxes (if less options are chosen it just shows the text 'please choose 4 options'). The test I setup in Ranorex uses one test case to check 4 different combinations of items and then checks the price whether it compares to an expected price (also included in an Excel-sheet that drives the suite). Generally this works as intended (sometimes it checks for the added price too quickly and gives an error because it compares the expected price to the text 'please choose 4 options', I added some delays but if I run the same suite multiple times it sometimes gets it right and sometimes doesn't, no idea why that is the case).
What I want is to create a list before the iterations and the testcase, then store a value/message when it validates the price in the list and in the end - thus after the iterations - print the list in the report. This sounds rather basic, but if I get this right I can enhance it much further. The overall idea behind this is that I want to create some sort of summary which I can manipulate further (for example: show detailed information about which configuration didn't show the correct price, how much the difference to the expected price was, et cetera).
For this I added a Setup region before my testcase and added a code module (named SummarySetup) who's only purpose it is to create a list:
I also added a Teardown region which contains a code block to print all the values:
- Whenever the Add line is used, I immediately get a StackOverFlowException and the whole test execution freezes. Somehow the line/method is repeatedly called upon but I have no idea how to fix this or work around it. I tried moving the line to another place but it still results in the Exception whenever it is reached.
- The report doesn't seem to use the method PrintItAll to log it into the report (which is empty below that line). When I add extra lines like 'Report.Info("Test") these do show up in the console window, but not in the report, which is where I want it to show up so I can extend upon it.
My C# code knowledge is lacking, but if I do this in Visual Studio it works as intended.
Thanks in advance for any help!
Maikel
I'm on Windows 10 Enterprise and using Ranorex Studio 7.1.0
I have a simple website with 4 combo boxes containing 4 items each which have a different value attribute each. When you choose 4 items, the added total (the 'price') is displayed below the boxes (if less options are chosen it just shows the text 'please choose 4 options'). The test I setup in Ranorex uses one test case to check 4 different combinations of items and then checks the price whether it compares to an expected price (also included in an Excel-sheet that drives the suite). Generally this works as intended (sometimes it checks for the added price too quickly and gives an error because it compares the expected price to the text 'please choose 4 options', I added some delays but if I run the same suite multiple times it sometimes gets it right and sometimes doesn't, no idea why that is the case).
What I want is to create a list before the iterations and the testcase, then store a value/message when it validates the price in the list and in the end - thus after the iterations - print the list in the report. This sounds rather basic, but if I get this right I can enhance it much further. The overall idea behind this is that I want to create some sort of summary which I can manipulate further (for example: show detailed information about which configuration didn't show the correct price, how much the difference to the expected price was, et cetera).
For this I added a Setup region before my testcase and added a code module (named SummarySetup) who's only purpose it is to create a list:
public static List<string> summaryList { get {return summaryList;} set {summaryList = value;} }The price-checker consists of a small code block, which has two arguments (the checked price and the expected price) and compares if these are equal (and logs both if/else through Report.Info("price correct/price incorrect"). To this end I added one extra line: namespace.SummarySetup.summaryList.add(chosen value).
I also added a Teardown region which contains a code block to print all the values:
public static void PrintItAll() { foreach(string a in namespace.SummarySetup.summaryList) { Report.Info(a); } }So long story, but two things are wrong here:
- Whenever the Add line is used, I immediately get a StackOverFlowException and the whole test execution freezes. Somehow the line/method is repeatedly called upon but I have no idea how to fix this or work around it. I tried moving the line to another place but it still results in the Exception whenever it is reached.
- The report doesn't seem to use the method PrintItAll to log it into the report (which is empty below that line). When I add extra lines like 'Report.Info("Test") these do show up in the console window, but not in the report, which is where I want it to show up so I can extend upon it.
My C# code knowledge is lacking, but if I do this in Visual Studio it works as intended.
Thanks in advance for any help!
Maikel