Search code examples
pythonandroidappiumappium-android

Appium Python start_activity with intents


My question is simple but yet hard to answer. I would like to launch my app with optional_intent_arguments. But since the python library of appium just supports 2 arguments I am kinda stuck and pissed.

I have tried Node js which is working perfectly but I don't want to recode everything I have done so far.

Error:

TypeError: start_activity() takes exactly 3 arguments (4 given)

Source code:

desired_caps = desired_caps = {
    'platformName': "Android",
    'platformVersion': "10",
    'deviceName': "my New Phone",
    'automationName': "UiAutomator2",
    'appPackage': mAppPackage,
    'appActivity': ".MainActivity",
    'avd': 'device' + str(mDeviceNr),
    'systemPort': str(mDeviceNr + 4722),
    'dontStopAppOnReset': 'true',
    'noReset': 'true'
}

mDriver = webdriver.Remote('http://127.0.0.1:' + str(mDeviceNr + 4722) + '/wd/hub', desired_caps)

mDriver.start_activity(mAppPackage, ".MainActivity", "<some intent argument in string>")

Without the extra argument, my App is starting perfectly and gets tested but the intent isn't there then.


Solution

  • KazuCocoa on github answered it for me.

    You can add arguments as keyword-arguments.

    e.g.

    mDriver.start_activity('xxx.xxx.xxx', '.MainActivity', app_wait_package='your package name')