Best practice question? New driver per test? Or reset app between tests, keeping driver alive

Hello all,

Looking for how other teams perform cleanup between tests. I currently create a driver per thread and reset app between tests, keeping the driver live throughtou the life of the test run, however with the removal of resetApp, I’m thinking that I shoudl create a deriver per test? create in before hook, .quit in the after hook. I feel this would add time to the tests, but at least it would be a fully clean driver instance. And my custom resetApp method is against what I believe is the advice from the appium team (based on them removing the resetApp method altogether).

What does everyone else do?

I am open driver each test which guarantees app to have predicted screen. It takes 2-3sec which is similar reset.

Also using strategy to start driver differently when needed → Different capabilities for different scenarios - #3 by Aleksei

1 Like

oh hey good idea. I have a few cases where I need to configure the driver, usually do this in a before step, but would probably be a bettter idea to create the driver afresh with teh correct configs.

        Map<String, Object> newSettings = new HashMap<>();
        newSettings.put("autoGrantPermissions", false);
        driver.setSettings(newSettings);

In most cases i use autoGrantPermissions to minimize taps on permissions.

While with test permissions tests I do not use it and use fastReset from mine config.

Any mine suite structure has first test Reset with fullReset option to remove old build and do some other stuff and then suite tests itself →

<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Change Plan suite" parallel="methods">
    <listeners>
        <listener class-name="core.utils.appium.RetryListener"/>
        <listener class-name="core.testrail.TestRailListener"/>
    </listeners>
    <parameter name="startType" value=""/>
    <parameter name="getClientVersion" value="true"/>
    <test name="reset">
        <parameter name="startType" value="fullReset"/>
        <classes>
            <class name="tests.resetClient"/>
        </classes>
    </test>
    <test name="ChangePlan">
        <packages>
            <package name="tests.changePlan.annualSubscription"/>
            <package name="tests.changePlan.annualSubscription.noFunds"/>
            <package name="tests.changePlan.downgrade"/>
            <package name="tests.changePlan.upgrade"/>
            <package name="tests.changePlan.upgrade.noFunds"/>
        </packages>
    </test>
</suite>