TestProject Forum
Powered by leading experts in the test automation community

Passive PASS of test step in Recording, to allow execution to continue and instead of halting everything

I need to check if an apps is present on the device screen (Android or iOS --> Home screen or second screen or third screen or ,). This need to be done while in “Recording” mode. The return would be TRUE or False (in boolResult per C# code in Visual Studio 2019). Also, regardless of the apps being found or not, the execution should be a passive PASS. With a Pass, the execution will move to the next instruction in the recording and not stop with a failure. At present I am trying to run the following instruction (created from TestProject Recording):

// 1. Is ‘Play Store2’ clickable?
by = By.XPath("//android.widget.TextView[@content-desc = ‘Play Store’]");
boolResult = driver.TestProject().IsClickable(by);
report.Step(“Is ‘Play Store2’ clickable?”, !(boolResult), TakeScreenshotConditionType.Never);

In this test step, there is no way to continue to the next step/instruction if the “PLAY STORE” apps is not found (CLICKABLE) on the current device screen (Android or iOS --> Home screen or second screen or third screen or ,). Perhaps, there is a different instruction/test step in Recording, that I can execute to get the TRUE or FALSE value in boolResult (to further use it in C# code in VS 2019) and I am not aware of it. There should be an entry in the test step in Recording, that will overwrite as a passive Pass, regardless of the test condition and the tester will be responsible for setting this condition. I hope I am making some sense and thanks for your help.

Hi @Wamiq.Sattar,

The scenario you are describing can be done by few actions (either in the recorder or in coded test).
In the Android example you described, you can check if a specific application is installed on the device using the “Execute Android shell command” action. The input to this action will be: adb shell pm list packages [your.package.name]

At your current state, you are trying to automate the home screen of your device and not the application that was set to this session.

What do you want to do next? after you check if the app is installed?

Also, in the code you attached: report.Step(“Is ‘Play Store2’ clickable?”, !(boolResult), TakeScreenshotConditionType.Never); why are reverting the boolResult in the Step method?

Can the “adb” command be executed from Recording stage, without and interaction from human factor?

I was reverting the boolResult, playing around to understand the capability test step/instruction.

The user can leave the icon on any screen, including the Home screen, My purpose is to go through each screen, including the Home screen, and see if the PLAY STORE icon in present. If the apps icon is not present then I try to Swipe to the left, assuming that the device in on the extreme right screen (say on screen #4 out of 1, 2, 3, 4 screens, Home being #1). If the apps is found on a particular screen, I will BREAK away (out of the loop) and tap on the apps icon to invoke it and proceed with what is next in the agenda. Here, I decided (Google) PLAY STORE apps. Necessarily, that’s not the apps I will be working with. Just used PLAY STORE apps to get going on Recording, etc.

Below is the C# code that I downloaded and added WHILE loop for the purpose:

// Starting from extreme right (end) screen and there are only 5 available screens
foundOnScreen = 0;
while (foundOnScreen <= 5) // Loop 5 time max and then get out, expecting that the apps will be found
{
// Is ‘Play Store2’ clickable?
by = By.XPath("//android.widget.TextView[@content-desc = ‘Play Store’]");
boolResult = driver.TestProject().IsClickable(by);
report.Step(“Is ‘Play Store2’ clickable?”, !(boolResult), TakeScreenshotConditionType.Never);

            Thread.Sleep(2000);

            if (boolResult == false)    // If boolResult is FALSE the SWIPE to go to the next screen on left
            {
                // Make a Swipe gesture from ('15','1344') to ('1364','1376')
                boolResult = driver.TestProject().SwipeGesture(15, 1344, 1364, 1376, 4344);
                report.Step("Make a Swipe gesture from ('15','1344') to ('1364','1376')", boolResult, TakeScreenshotConditionType.Failure);
                Thread.Sleep(2000);

                foundOnScreen++;
            }
            else
            {
                break;      // Okay, boolResult= TRUE. found the apps
            }
        }

        // Tap 'Play Store2' to invoke the apps on the device screen
        by = By.XPath("//android.widget.TextView[@content-desc = 'Play Store']");
        boolResult = driver.TestProject().Tap(by);
        report.Step("Tap 'Play Store2'", boolResult, TakeScreenshotConditionType.Failure);
        // Add step sleep time (After)
        Thread.Sleep(5000);

Hi @wamiq_sattar,

You can save all that trouble by simply use the adb command. It’s an action that you can use both in the recorder and in your coded test. No intraction from human is needed.

Using this action, will save you all the hard work of swiping and searching for the Play Store app in all of the home screens.

Let me know if you will need my help with that.

That’s great that “adb” will allow me to test and see if the apps exists on the device. Yes, I will need help with that adb, as I am totally new to automation! I will send you an email. Thanks.