Launch_app() alternative in Appium-Python-Client(v3.0.0)

I am performing mobile automation on a real device. With Appium 2.0 i was facing issues while launching app, so i was using launch_app() method to hard launch it every time i run it. But with the latest Appium-Python-Client (v3.0.0) launch_app() method has been deprecated.

And without launch_app() my app rarely launches. Below is my code for reference.

from appium import webdriver

class MyAPP:
    def __init__(self,device_name:str=DEVICE_NAME, environment:str=DEFAULT_ENVIRONMENT)->None:
        self.environment                                           = environment
        envPackage                                                 = '.staging' if environment=="Staging" else ''
        desiredCapabilities                                        = {}
        desiredCapabilities["appium:deviceName"]                   = device_name
        desiredCapabilities["appium:automationName"]               = AUTOMATION_NAME
        desiredCapabilities["appium:platformName"]                 = PLATFORM_NAME
        desiredCapabilities["appium:platformVersion"]              = ANDROID_VERSION
        desiredCapabilities["appium:appPackage"]                   = f'{APP_PACKAGE}{envPackage}' #APP_PACKAGE
        desiredCapabilities["appium:appActivity"]                  = APP_ACTIVITY
        desiredCapabilities["appium:instrumentApp"]                = True
        desiredCapabilities["appium:ensureWebviewsHavePages"]      = True
        desiredCapabilities["appium:nativeWebScreenshot"]          = True
        desiredCapabilities["appium:newCommandTimeout"]            = NEW_COMMAND_TIMEOUT
        desiredCapabilities["appium:connectHardwareKeyboard"]      = True
        desiredCapabilities["appium:noReset"]                      = True
        options = UiAutomator2Options()

        # starting session based on set capabilities
        self.driver = webdriver.Remote(SERVER_URL, options=options)
        # hard launch app 
        self.driver.launch_app()    #### deprecated 

I tried to go through documentation and find an alternative method to hard launch my app but i am not getting any. Please help.

In the second link you provided in the first comment it says:

terminate_app and activate_app to restart the app

Are these not working for you?

Thank you so much. It worked.

1 Like

Hi, can you show some example to use terminate_app ? i really need help on activate and terminate app, bcos my framework store test cases in excel and need to activate and close driver for different test case.

I don’t know how many you need but it’s pretty basic:


Here is the command reference: