Auto-apply Rules | Bondar Academy
Course: Mastering testRigor
Module: Reusability and Optimization
Instructor: Artem Bondar
Lesson Summary
In this lesson, we explore how to apply AutoApplyRules in testing scenarios, particularly when dealing with unpredictable user flows, such as a Random Dialog feature. Key Concepts Random Dialog: A feature where users can enter names, but may encounter a friendly reminder that requires names to start with a capital letter. Automation Challenges: The random nature of reminders makes it difficult to predict user flow, complicating automation efforts. If-Else Conditions: A traditional method to handle such situations, but not always efficient. AutoApplyRules: A more effective solution provided by Test Trigger to manage unpredictable user interactions. Creating an AutoApplyRule Navigate to the Model and Overlays section and open the Dialog page. Set up a test case to enter names and observe the friendly reminder. When the reminder appears, create an AutoApplyRule to automatically click the OK button. Define the trigger condition: when the page contains the friendly reminder. Enable the auto apply on every step option for the rule. Testing the Rule After creating the rule, rerun the test case. The rule should automatically apply when the friendly reminder appears, allowing the test to pass successfully. Summary: Use AutoApplyRules to handle random situations in user flows by defining conditions for automatic actions, ensuring smoother test automation.
Video Transcript
In this lesson, we will talk about how to apply rules. So what is it and the use case, when to use it. So let's get into it. Going back to our application and navigate to Model and Overlays and to Dialog page. And here we have the section Random Dialog. And let me show you the feature about this Random Dialog. So I click Enter the name and can type any name, for example, John, and click Submit. And we have this name showed up here in the list of names. Then I click Name again. I see this one more time. I type any name and click Submit, click again. And right now I have this friendly reminder. Reminder name should start with a capital case. I click OK, and now I have this input field to enter a new name and click Submit. Click again, and now I have this reminder again. So this friendly reminder popup is a kind of a random attribute of the user flow. And you cannot predict when this friendly reminder will be displayed on the page. And automation of this type of functionality is kind of difficult because you can't predict exactly your user flow. One of the ways how to handle this is using if-else conditions. But Test Trigger has another solution for this called AutoApplyRules. And let's create the scenario using AutoApplyRules. So going back to the test cases, and let me create, first of all, a new test case with this functionality. Enter name into random dialog section. Okay, the first thing we need to navigate to, where is this, model and overlays. Model and overlays. And then click on dialog to open dialog page right here. Then the next step, what we need to do is click on Enter Name. We ignore this for now, and type into the name input field, and then click Submit. So let's add those steps as well. Click Enter Name. Click Input Name. Type any name, for example, John. And then click Submit. Something like that, right? And let me repeat this step several times with different name. For example, John, Tom, and I don't know, Mike, something like this. And yeah, let me run this test, and it expectedly should fail in some of the iteration steps. Add and run. Yeah, and here we go, test failed. So we were able to enter a couple of names. So this is Tom. You can see two names are added in the list of names. But when we try to enter the third name, here we go. We have this friendly reminder, random pop-up, which is showed up. And that's why we were not able to enter a third name. So now we can create auto-apply rule, which will monitor the flow of our scenario. And if the friendly reminder is displayed on the page, then it will click on the OK button for us in order to continue the flow. So let's create auto-apply rule. Going back to the rules, and I create a new rule. So I would call it confirm the friendly reminder. So this rule is related to dialog page. And also I would like to add a second label, which is auto-apply rule. So if later I need to search which of my rules are auto-apply rules, I can use this label. And now I need to perform the step for this rule. So what step will it be? The step will be is, so let me trigger this one more time. Here we go. So we need to click on OK button below friendly reminder. So let's do this. Click OK, click button OK below, and below friendly reminder. Okay, here we go. So the step is created. Now we need to create a trigger and to say that this is auto-apply rule. Scroll a little bit down here under this drop down, you can find the section auto-apply on every step of every test case. So click this checkbox. And here in precondition step, need to define the condition when this rule have to be triggered. And for us, the definition is pretty easy. So when this friendly reminder is displayed on the page, then we want to trigger this rule and click on OK button. And I will type precondition, check that page contains, and contains friendly reminder. All right, and I click Save. That's it. A new rule was created and we don't need to add this rule anywhere inside of the test case. It will be automatically applied to any test case. If the friendly reminder will be displayed on the page, this step will be triggered. So all we need to do is just to rerun our test and see if this rule will be applied or not. And I click Retest. All right, and test passed successfully. So now let's check the steps. So this is the first name that we entered. Here we go. Over here, we type John. Then we entered this name, click again. We type the next name, Tom. Added the second guy. And then here we go. This is our friendly reminder. And now you can see that rule was triggered. Friendly reminder displayed on the page. And we click OK button below friendly reminder. It was clicked. And now the window, click. We submit the last name, Mike. Submit and test pass successfully. All right, so this is how auto apply rules work in the test trigger. And let's quickly summarize what we did in this lesson. So when you have a random kind of situation in your user flow with a user interface that you can't control during the normal user flow, the auto apply rule is the way to go to handle this. You need to create a new rule, the action that have to be performed. You need to click auto apply on every step checkbox over here and define the condition when this rule have to be triggered inside of the user flow. Auto apply rule should not be defined inside of the test case. It will be triggered automatically based on the defined condition. All right, that's it guys and see you in the next lesson.