使用机器人框架打开应用时,Appium提供错误

时间:2019-01-09 18:28:02

标签: robotframework appium-android

这是我的代码,我看到该应用程序在模拟器中打开,然后关闭,但仍然出现此错误

** Variables ** 
${REMOTE_URL} http://localhost:4723/wd/hub
${PLATFORM_NAME_ANDROID} Android
${DEVICE_NAME_ANDROID} emulator-5554
${APP_ANDROID} /Users/william_flow/Documents/Code/xxx/App/base.apk
${APP_PACKAGE} com.xxx.android
${AUTOMATION_NAME} appium
${RESET_OFF} true
${AppAct} com.xxx.android.flavor.full.activities.HomeActivity

** Test Cases *
Open Android app
Open Application ${REMOTE_URL} app=${APP_ANDROID} 
automationName=${AUTOMATION_NAME} 
platformName=${PLATFORM_NAME_ANDROID} 
deviceName=${DEVICE_NAME_ANDROID} appPackage=${APP_PACKAGE} 
noReset=${RESET_OFF}
sleep 5s

我运行它,发现它在模拟器中运行,失败了

Open Android app | FAIL |
WebDriverException: Message: An unknown server-side error occurred 
while processing the command. Original error: Cannot start the 
‘com.xxx.android’ application. Visit 
https://github.com/appium/appium/blob/master/docs/en/writing-running- 
appium/android/activity-startup.md for troubleshooting. Original 
error: ‘com.xxx.android.activities.MainActivity’ or 
‘com.xxx.android.com.xxx.android.activities.MainActivity’ never 
started. Visit 
https://github.com/appium/appium/blob/master/docs/en/writing-running- 
appium/android/activity-startup.md for troubleshooting

那我在做什么错了?

1 个答案:

答案 0 :(得分:0)

我已经修改了您的代码,以使它变得更可重编并且易于执行

*** Settings ***
Documentation    This script starts apps on two phones
Library          AppiumLibrary
Library          Collections

*** Variables ***
${REMOTE_URL}  http://localhost:4723/wd/hub
${PLATFORM_NAME_ANDROID}  Android
${DEVICE_NAME_ANDROID}  emulator-5554
${APP_ANDROID}  /Users/william_flow/Documents/Code/xxx/App/base.apk
${APP_PACKAGE}  com.xxx.android
${AUTOMATION_NAME}  appium
${RESET_OFF}  true
${AppAct}  com.xxx.android.flavor.full.activities.HomeActivity

*** Test Cases ***
First test case
    Open Android app

*** Keywords ***
Open Android app
    Open Application  ${REMOTE_URL}  app=${APP_ANDROID}  automationName=${AUTOMATION_NAME}  platformName=${PLATFORM_NAME_ANDROID}  deviceName=${DEVICE_NAME_ANDROID}  appPackage=${APP_PACKAGE}  noReset=${RESET_OFF}  appActivity=${AppAct}
    sleep 5s

关键点对

  1. appActivity 丢失了
  2. 假设 appium服务器在4723上运行
  3. 假设已安装 Appium库
  4. 您可能还想看看此链接Automating mobile App using Robot Framework and Appium

如果您可以解决4分以上的问题,您的错误应该得到解决!