Different capabilities for different scenarios

Hi guys,

I’m testing an android app with Appium + Cucumber + Ruby. I need to reinstall (or clear data) the app for some scenarios and for some scenarios I don’t need that (or at least just restart the app). I mean if I’m running test for a feature, is it possible to specify that for each scenario? How can I do that? Thank you

I have a test that puts my app into a state that a customer would never see. It’s the last test in a suite, and I restart the driver to clear data. The way I do it is to tag my scenario with an @restart and then in my hooks.rb I add the following:

After('@restart') do
  restart_driver
end

restart_driver looks like this:

def restart_driver
  driver.reset
end

Read more about tagged hooks here:

2 Likes

i am solving it with testNG by specifying parameter like: fullReset, fastReset and nothing.
in “beforeMethod” i am reading this parameter and specify how driver to start:

        if (devicePlatform.contains("fullReset")) { // uninstall and install client
            System.out.println("  Driver DO FULL-RESET");
            capabilities.setCapability(MobileCapabilityType.FULL_RESET, true);
            capabilities.setCapability(MobileCapabilityType.NO_RESET, false);
        } else if (devicePlatform.contains("fastReset")) { // clears cache and settings without reinstall
            System.out.println("  Driver DO FAST-RESET");
            capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
            capabilities.setCapability(MobileCapabilityType.NO_RESET, false);
        } else { // just start client
            System.out.println("  Driver DO NORMAL start"); 
            capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
            capabilities.setCapability(MobileCapabilityType.NO_RESET, true);
        }

normally i do ONE test with fullReset to install new version, min possible number of tests with fastReset (cause it is slowing start) and all other tests with normal start.

in testNG it is look like:

<!DOCTYPE suite SYSTEM "http://beust.com/testng/testng-1.0.dtd" >
<suite name="BVT_Android">
    <test name="doReinstall" preserve-order="true">
        <parameter name="devicePlatform" value="android fullReset"/>
        <parameter name="deviceName" value="loc_Sony_Z1"/>
        <classes>
            <class name="com.xxxx.tests.android.test_1">
                <methods>
                    <include name="test_reinstall"></include>
                </methods>
            </class>
        </classes>
    </test>
   <test name="doReset" preserve-order="true">
        <parameter name="devicePlatform" value="android fastReset"/>
        <parameter name="deviceName" value="loc_Sony_Z1"/>
        <classes>
            <class name="com.xxxx.tests.android.test_2">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
            <class name="com.xxxx.tests.android.test_3">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
            ....
        </classes>
    </test>
   <test name="normalStart" preserve-order="true">
        <parameter name="devicePlatform" value="android"/>
        <parameter name="deviceName" value="loc_Sony_Z1"/>
        <classes>
            <class name="com.xxxx.tests.android.test_4">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
            <class name="com.xxxx.tests.android.test_5">
                <methods>
                    <include name="test_1"></include>
                    <include name="test_2"></include>
                </methods>
            </class>
            ....
        </classes>
    </test>
</suite>

Hello Alekesi
I have a question for you
Q:what was the particular desired capabilites we need to set it will tell
appium not to re-install the application on device.

@shadabaliara71 i mentioned litttle before. Check above.

Hi @Aleksei. i am new for appium. i think this logical part we need to add in script i am right…

else if (devicePlatform.contains(“fastReset”)) { // clears cache and settings without reinstall
System.out.println(" Driver DO FAST-RESET");
capabilities.setCapability(MobileCapabilityType.FULL_RESET, false);
capabilities.setCapability(MobileCapabilityType.NO_RESET, false);
}

@shadabaliara71 it is depending do you want RESET client before test or not. If want RESET then right, if NO then use last case.

Hi @Aleksei thanks for reply
Q:can you please tell me how to perfome pinch and flick zoom in,zoom out operation on mobile device or image?

Hello @Aleksei
can you please suggest me which portal in best for learnig mobile Appium testing?.I want to learn appium
m waiting for your reply

@Appium_Learner

Links from google first page results below.Start trying, making mistakes its normally the best way to learn. Anything that you get stuck in (try to resolve on your own first) ask in here with code and screenshot from inspectors.

For pinch and zoom, play with TouchAction and MultiTouchAction.

http://toolsqa.com/mobile-automation/appium/appium-tutorial/
https://www.guru99.com/introduction-to-appium.html


Thanks @Telmo_Cardoso I have a Question.
Q:I want to test android native apps but i dont have a .apk file how to install the apps on mobile device?
2. how to launch apps by using appium server.?

You don’t have the apk, but its already installed on device? Do you know the package name and launcher activity?

one of my friend in interview panel the faced this question i just want to know any alternative way is there to launch and test apps …

if you dont have the apk, you can use one that is already installed in device. just use the following capabilities:

capabilities.setCapability(AndroidMobileCapabilityType.APP_ACTIVITY, "replace by start activity");
capabilities.setCapability(AndroidMobileCapabilityType.APP_PACKAGE, "replace by android package");

I understand this way " suppose 1.0 version all ready install in my device after some modification dev team release 1.1 v to testing team but they doesn’t give the apk file.that time we need to set that desied capabilites in our script"…I am correct @Telmo_Cardoso

Q:suppose you are worked on new project first build release 1.0v apps is not already install in your device they dont give you .apk file that time how you install and test?

Forget the automation. How do you install and test app manually without it installed in device or without having the apk?

Hi @Telmo_Cardoso thanks for response your sugesstion is very helpful to me.I have a question
Q:how to automate otp verification can you please provide the script ?

You can check this topic to start having some ideas:

Hi @Telmo_Cardoso thanks for quick response.
is it necesaary to used sms reader app for otp verifaction any alternate way is there…
Q:how to handle popups in navtive apps is it possible.based on my knowldege web view apps we can handle popup by using alert interface.

Hi @Appium_Learner I use sms reader app, because each Android has one different native SMS default app and I would have to find a way to automate hundreds of different devices. Using that sms reader was the solution I found. There might be others.

I can check popups in the same way I verify all the rest…