无法运行python(mac)的自动化脚本

时间:2018-07-09 03:43:00

标签: python python-3.x appium appium-android python-appium

我正在使用https://github.com/appium/python-client框架来运行自动化。

我在运行脚本时遇到错误。

  

异常:消息:发生未知的服务器端错误   处理命令。原始错误:   packageAndLaunchActivityFromManifest失败。原始错误:无法   寻找合适的对象请使用以下命令设置ANDROID_HOME环境变量   Android SDK根目录路径。

此外,我在Mac上设置了ANDROID_HOME环境变量。

有人知道如何解决吗?

1 个答案:

答案 0 :(得分:3)

此错误与您正在使用的库无关。请在终端中运行appium-doctor并查看输出。应该是这样的

    info AppiumDoctor Appium Doctor v.1.4.3
    info AppiumDoctor ### Diagnostic starting ###
    info AppiumDoctor  ✔ The Node.js binary was found at: /usr/local/bin/node
    info AppiumDoctor  ✔ Node version is 6.11.0
    info AppiumDoctor  ✔ Xcode is installed at: /Applications/Xcode.app/Contents/Developer
    info AppiumDoctor  ✔ Xcode Command Line Tools are installed.
    info AppiumDoctor  ✔ DevToolsSecurity is enabled.
    info AppiumDoctor  ✔ The Authorization DB is set up properly.
    info AppiumDoctor  ✔ Carthage was found at: /usr/local/bin/carthage
    info AppiumDoctor  ✔ HOME is set to: /Users/poornima
    info AppiumDoctor  ✔ ANDROID_HOME is set to: /Users/poornima/Library/Android/sdk
    info AppiumDoctor  ✔ JAVA_HOME is set to: /Library/Java/JavaVirtualMachines/jdk1.8.0_144.jdk/Contents/Home
    info AppiumDoctor  ✔ adb exists at: /Users/poornima/Library/Android/sdk/platform-tools/adb
    info AppiumDoctor  ✔ android exists at: /Users/poornima/Library/Android/sdk/tools/android
    info AppiumDoctor  ✔ emulator exists at: /Users/poornima/Library/Android/sdk/tools/emulator
    info AppiumDoctor  ✔ Bin directory of $JAVA_HOME is set
    info AppiumDoctor ### Diagnostic completed, no fix needed. ###
    info AppiumDoctor 
    info AppiumDoctor Everything looks good, bye!
    info AppiumDoctor 

如果不是

确保您的工具和平台工具也已添加到bash配置文件中的path变量中。

  1. 打开bash配置文件open ~/.bash_profile

  2. 添加工具和平台工具

    export ANDROID_HOME=/Users/poornima/Library/Android/sdk
    export PATH=$ANDROID_HOME/platform-tools:$PATH
    export PATH=$ANDROID_HOME/tools:$PATH
    

请参考以下链接:Could not find aapt with appium server