Is there a way to check if X rules are matched in a smart folder?

Technology specific object identification, supported applications, web technologies, and 3rd party controls.
Posts: 31
Joined: Fri Jul 02, 2021 2:35 pm

Is there a way to check if X rules are matched in a smart folder?

Post by QATest879 » Tue Sep 07, 2021 5:20 pm

Under "If condition..." for a smart folder, the Condition tab has an area for rules that you can add. For example "only run the recordings in this smart folder IF the following rule is matched." And there are two options:

"Run this test container if any of the following rules are matched:"
"Run this test container if all of the following rules are matched:"

I have actually encountered a scenario where I only want to run the smart folder if any two out of three of the rules are matched... Since it's 2/3, it doesn't really fit into either of those categories. I'm just wondering if there's a simple way to do this? If not, I will still be able to do it, I can just make a variable that is true if one out of the first two rules are matched, and then a second variable for the third rule, and then I just need to check tbat "all" rules are matched and use the two variables, if that makes sense. That will definitely work out though, but I'm just wondering for my reference if there's any other way to check if x rules are matched?

Thank you.

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

Re: Is there a way to check if X rules are matched in a smart folder?

Post by odklizec » Wed Sep 08, 2021 8:00 am


I'm afraid, there is no out-of-the-box solution to what you want. I'm personally using conditional smartfolders only for very simple conditions. For more complex conditions, it's probably better (and only) solution to disable/enable smartfolders via code. I'm using something like this in my projects:

Code: Select all

var curTestCase = (TestCaseNode)TestSuite.CurrentTestContainer; 
if (curTCName == "GPU_Validate")
	var getTestCase = TestSuite.Current.GetTestContainer("GPU_RepeatFileUpload_" + cm_Customer);
	string fileName = getTestCase.DataContext.CurrentRow.Values[0];
	int tcIteration = TestSuite.Current.GetTestContainer("GPU_Configuration").DataContext.CurrentRowIndex;

	if ((tcIteration == 1 & (fileName == "1.csv" | fileName == "2.csv" | fileName == "6.csv")) | (tcIteration == 2 & (fileName == "1.csv" | fileName == "2.csv" | fileName == "3.csv" | fileName == "6.csv")))
		TestSuite.Current.GetTestContainer("GPU_Validate_1").Checked = true;
		TestSuite.Current.GetTestContainer("GPU_Validate_2").Checked = false;
		TestSuite.Current.GetTestContainer("GPU_Validate_1").Checked = false;
		TestSuite.Current.GetTestContainer("GPU_Validate_2").Checked = true;
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