Monday, 9 October 2023

launch_app() alternative in appium python

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.

class MyAPP:
    @log
    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()
        options.load_capabilities(desiredCapabilities)

        # 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 the docs but i did not get anything. Please help.



from launch_app() alternative in appium python

No comments:

Post a Comment