I am performing mobile automation on a real device. With Appium 2.0, I was facing issues while launching the app, so I was using the launch_app() method to hard launch it every time I ran 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 documentation, but I did not get anything. How can I fix it?
You can just try with:
It will bring your app to the main thread.