在Android第三方设备上运行appium必须使用哪些文件?

时间:2015-02-21 01:53:11

标签: java android automation ui-automation appium

我第一次使用appium。我想在第三方安装的应用程序上运行简单的自动化。我想为该特定应用配置appium服务器。

我几乎没有问题:

  1. 哪些字段是强制性的?

  2. 我必须手动填写它们吗?因为我的Android插入了mac, 然而,我无法自动完成名称。

  3. 如何轻松找到所需的应用apk路径和它的启动活动(我猜双击apk之后?)

  4. enter image description here

    更新

    我现在收到以下错误:

    不起作用。

    新的控制台开启了:

    ➜  ~  echo $JAVA_HOME
    /Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home
    

    医生:

    运行Android检查

    ✔ ANDROID_HOME is set to "/Users/eladb/MyWorkspace2/adt-bundle-mac-x86_64/sdk/"
    ✔ JAVA_HOME is set to "/Library/Java/JavaVirtualMachines/jdk1.7.0_71.jdk/Contents/Home."
    ✔ ADB exists at /Users/eladb/MyWorkspace2/adt-bundle-mac-x86_64/sdk/platform-tools/adb
    ✔ Android exists at /Users/eladb/MyWorkspace2/adt-bundle-mac-x86_64/sdk/tools/android
    ✔ Emulator exists at /Users/eladb/MyWorkspace2/adt-bundle-mac-x86_64/sdk/tools/emulator
    ✔ Android Checks were successful.
    
    ✔ All Checks were successful
    ➜  ~
    
    然而,appium说:

    info: [debug] Responding to client with success: {"status":0,"value":{"build":{"version":"1.3.5","revision":"a124a15677e26b33db16e81c4b3b34d9c6b8cac9"}}}
    info: <-- GET /wd/hub/status 200 0.927 ms - 104 {"status":0,"value":{"build":{"version":"1.3.5","revision":"a124a15677e26b33db16e81c4b3b34d9c6b8cac9"}}}
    
    info: --> POST /wd/hub/session {"desiredCapabilities":{"appPackage":"com.grindrapp.android","appActivity":".activity.SplashActivity","platformVersion":"4.4.2","browserName":"","platformName":"Android","deviceName":"10.0.0.9:5555"}}
    
    info: Client User-Agent string: Apache-HttpClient/4.3.4 (java 1.5)
    
    info: [debug] Didn't get app but did get Android package, will attempt to launch it on the device
    
    info: [debug] Creating new appium session e232fa9d-a70c-4de9-84e7-d86441cc9dc6
    
    info: Starting android appium
    
    info: [debug] Getting Java version
    
    info: [debug] Cleaning up android objects
    
    info: [debug] Cleaning up appium session
    
    info: [debug] Error: Could not get the Java version. Is Java installed?
        at /Applications/Appium.app/Contents/Resources/node_modules/appium/lib/devices/android/android-common.js:1040:17
        at ChildProcess.exithandler (child_process.js:735:7)
        at ChildProcess.emit (events.js:110:17)
        at maybeClose (child_process.js:1008:16)
        at Socket.<anonymous> (child_process.js:1176:11)
        at Socket.emit (events.js:107:17)
        at Pipe.close (net.js:476:12)
    
    error: Failed to start an Appium session, err was: Error: Could not get the Java version. Is Java installed?
    
    info: [debug] Responding to client with error: {"status":33,"value":{"message":"A new session could not be created. (Original error: Could not get the Java version. Is Java installed?)","origValue":"Could not get the Java version. Is Java installed?"},"sessionId":null}
    info: <-- POST /wd/hub/session 500 87.838 ms - 222 
    
    info: --> GET /wd/hub/status {}
    

    我使用的是appium 1.3.5

1 个答案:

答案 0 :(得分:0)

您需要提及以下字段:

  1. App path
  2. 包名称
  3. 启动活动(您可以要求开发人员查找apk文件的启动活动)
  4. 设备
  5. SDK路径
  6. Bootstrap port
  7. 服务器地址(默认为127.0.0.1)
  8. 端口(默认情况下,它在4723上运行)
  9. 如果您不想在Appium中提及这些内容,您还可以使用功能类在脚本中提及它。

    DesiredCapabilities capabilities = new DesiredCapabilities();
                capabilities.setCapability("platformName", "Android");
                capabilities.setCapability("deviceName", "Android");
                capabilities.setCapability("platformVersion", "4.4.2");
                capabilities.setCapability("appPackage", "something");
                capabilities.setCapability("appActivity", "something");
                capabilities.setCapability("udid", udid);