Different capabilities for different scenarios

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 for Android / reinstall app for iOS
            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>
1 Like
To launch a app which is already logged in?
App re-builds every time while stating the execution on iOS device with appium 1.6.5
driver.resetApp and accounts data
WhatsApp opening to wrong screen
How to reset the app state when running through a new test?
Installing the application on the iOS phone is very slow
Real device issue in iOS 13.4 and xcode 11.2
How to open Login screen before each test case in iOS real device
Best practice question? New driver per test? Or reset app between tests, keeping driver alive
When try to record video in real device iOS
Android Driver RemoveApp
Appium to not install app again but only reset app data
Problem with run all tetst in case - cant find element
Command line in appium
Permissions capability in iOS
Capabilities noReset
Issue with installing Appium UIAutomator2 on virtual device
Prevent iOS app from resetting on launch
How to make user stay logged in during tests
Remove app after call "close_app()"
How to clear the cache of iOS apps and launch it again?
Wait For Running TestCases Until appium installs Apk on my devices
UsePrebuiltWDA vs Attach to Running WDA
Manter Dados do APP Salvos com Appiun
How to install app and don't reinstall it for each test(for configuration skipping)
Appium cannot get the webview content when the 'app' capabilities is null
"Messages" in Google Maps are getting cleared when launched the "Google Maps" using Appium
Is there a way Open and Close the app under test?
Maintain Login for multiple tests using Python