简体   繁体   中英

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.

KazuCocoa on github answered it for me.

You can add arguments as keyword-arguments.

eg

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM