• 嗯,我网关应该怎么设置,设置多少呢?我现在设置的是 2-3 图中的,192.168.106.2

  • 感谢~ 昨天终于找到问题原因了,已解决。

  • 使用 Appium UIAutomator2 pressKeyCode(66) 不生效,server 也没有报错。你遇到了吗?
    问题详情见下方链接帖子,感谢~

    Appium 中使用 pressKeyCode 方法不起作用也没有报错

  • @slideplustest @xiaozi2400-github
    试了在需要 pressKeyCode(66) 时,先切换到第三方输入法,再使用 pressKeyCode(66) 方法。
    结果还是一样,server 无报错信息,但是并未生效。

    启用第三方输入法

    /**
     * 启用华为百度输入法
     */
    public void setHuaWeiInput() {
        logger.info("setHuaWeiInput 启用华为百度输入法");
        excuteAdbShell("adb shell ime set com.baidu.input_huawei/.ImeService");
    }
    

    server 端日志如下

    [HTTP] <-- POST /wd/hub/session/976abb7b-e49d-4318-bd28-223ee348804d/element/2ae448f9-e1e0-418d-b1a0-fb3a7cf7980c/value 200 675 ms - 74 
    [HTTP] --> POST /wd/hub/session/976abb7b-e49d-4318-bd28-223ee348804d/appium/device/press_keycode {"keycode":66}
    [MJSONWP] Calling AppiumDriver.pressKeyCode() with args: [66,null,null,null,"976abb7b-e49d-4318-bd28-223ee348804d"]
    [JSONWP Proxy] Proxying [POST /appium/device/press_keycode] to [POST http://localhost:8201/wd/hub/session/04125e0b-739c-4d71-a822-efe2cd90baad/appium/device/press_keycode] with body: {"keycode":66,"metastate":null}
    [JSONWP Proxy] Got response with status 200: {"sessionId":"04125e0b-739c-4d71-a822-efe2cd90baad","status":0,"value":true}
    [MJSONWP] Responding to client with driver.pressKeyCode() result: true
    [HTTP] <-- POST /wd/hub/session/976abb7b-e49d-4318-bd28-223ee348804d/appium/device/press_keycode 200 589 ms - 76 
    [HTTP] --> POST /wd/hub/session/976abb7b-e49d-4318-bd28-223ee348804d/appium/device/press_keycode {"keycode":66}
    [MJSONWP] Calling AppiumDriver.pressKeyCode() with args: [66,null,null,null,"976abb7b-e49d-4318-bd28-223ee348804d"]
    [JSONWP Proxy] Proxying [POST /appium/device/press_keycode] to [POST http://localhost:8201/wd/hub/session/04125e0b-739c-4d71-a822-efe2cd90baad/appium/device/press_keycode] with body: {"keycode":66,"metastate":null}
    [JSONWP Proxy] Got response with status 200: {"sessionId":"04125e0b-739c-4d71-a822-efe2cd90baad","status":0,"value":true}
    [MJSONWP] Responding to client with driver.pressKeyCode() result: true
    
    
  • @charles_joker_lee 求助,使用 Appium UIAutomator2 pressKeyCode(66) 不生效,server 也没有报错。
    问题详情见下方链接帖子,感谢~

    Appium 中使用 pressKeyCode 方法不起作用也没有报错

  • Appium 开源分享优化版 at 2018年03月22日

    那这种问题怎么处理呢?我现在卡在这里了......当把启动参数设置成automationName=Appium,pressKeyCode 就正常了。就不能使用 uiautomator2 处理 toast 了。

  • Appium 开源分享优化版 at 2018年03月19日

    问下楼主,有没有遇到使用 UIAutomator2,调用 pressKeyCode(66) 方法无效的情况?server 无报错,但是 app 上面也没起作用。

  • 求指点迷津,感谢

  • appium java 试了下加到启动参数中也没有起作用啊

  • 我也是在搞这一块纠结着,通过 AppiumDriver 的方式实现时,会有很多 AndroidDriver 的方法不可用。比如 hideKeyBoard() 等方法不能调用。楼主有什么好方法希望分享下。

  • @junhe macaca 有没有提供官方的方法封装,对应处理下拉框、单选框、复选框的操作呢? 求 JAVA 示例

  • macaca 对于单选框复选框 checkbox,是不是也没有现成方法支持啊?楼主也是通过这种方法处理的吗?

  • 感谢,使用楼主方法亲测成功。Google Chrome 61.0.3163.100 (正式版本)(64 位)(cohort: Stable)
    本人 macaca doctor 信息如下,供参考:

    C:\Users\KingDow>macaca doctor
    
      macaca-doctor version: 2.0.3
    
    
      Node.js checklist:
    
      node env: C:\Program Files\nodejs\node.exe
      node version: v8.2.1
    
      Android checklist:
    
      JAVA version is `1.8.0_141`
      JAVA_HOME is set to `E:\WORKTOOLS\jdk\jdk-8u141-windows-x64`
      ANDROID_HOME is set to `E:\autoTest\macaca\tools-new\sdk`
      Platforms is set to `E:\autoTest\macaca\tools-new\sdk\platforms\android-26`
      ADB tool is set to `E:\autoTest\macaca\tools-new\sdk\platform-tools\adb.exe`
      GRADLE_HOME is set to `E:\autoTest\macaca\tools-new\gradle\gradle-4.0.1`
    
      Installed driver list:
    
      android: 2.0.40
      chrome: 1.0.7
      electron: 1.1.11
      ios: 2.0.24
    
  • @hivencent 麻烦楼主贴一下你的 macaca doctor 看一下吧,看下各个版本的对应,谢谢。

  • 你好,我启动 app-inspector 报错:

    Microsoft Windows [版本 10.0.15063]
    (c) 2017 Microsoft Corporation。保留所有权利。
    
    C:\Users\KingDow>app-inspector -u 192.168.189.101:5555 --verbose
    >> request.js:24:12 [master] pid:24900 get remote update info failed.
    >> server.js:16:12 [master] pid:24900 server start with config:
     { port: 5678,
      verbose: true,
      udid: '192.168.189.101:5555',
      ip: '10.30.27.84',
      host: 'DESKTOP-7ONAIHS',
      loaded_time: '2017-08-19 19:01:39' }
    >> app-inspector.js:43:12 [master] pid:24900 server start at: http://10.30.27.84:5678
    { Error: Command failed: E:\autoTest\macaca\tools-new\sdk/platform-tools/adb -s 192.168.189.101:5555 push C:\Users\KingDow\AppData\Roaming\npm\node_modules\app-inspector\node_modules\_uiautomatorwd@1.0.42@uiautomatorwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing
    
        at ChildProcess.exithandler (child_process.js:270:12)
        at emitTwo (events.js:125:13)
        at ChildProcess.emit (events.js:213:7)
        at maybeClose (internal/child_process.js:921:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
      killed: false,
      code: 1,
      signal: null,
      cmd: 'E:\\autoTest\\macaca\\tools-new\\sdk/platform-tools/adb -s 192.168.189.101:5555 push C:\\Users\\KingDow\\AppData\\Roaming\\npm\\node_modules\\app-inspector\\node_modules\\_uiautomatorwd@1.0.42@uiautomatorwd\\app\\build\\outputs\\apk\\app-debug.apk /data/local/tmp/com.macaca.android.testing' }
    
    

    浏览器访问http://10.30.27.84:5678Waiting,页面一直显示: device start,一直刷新,后台显示 Get 200。genymotion 已经启动虚拟机以及 app 了。

    安装信息如下:

    C:\Users\KingDow>macaca doctor
    
      macaca-doctor version: 2.0.2
    
    
      Node.js checklist:
    
      node env: C:\Program Files\nodejs\node.exe
      node version: v8.2.1
    
      Android checklist:
    
      JAVA version is `1.8.0_141`
      JAVA_HOME is set to `E:\WORKTOOLS\jdk\jdk-8u141-windows-x64`
      ANDROID_HOME is set to `E:\autoTest\macaca\tools-new\sdk`
      Platforms is set to `E:\autoTest\macaca\tools-new\sdk\platforms\android-26`
      ADB tool is set to `E:\autoTest\macaca\tools-new\sdk\platform-tools\adb.exe`
      GRADLE_HOME is set to `E:\autoTest\macaca\tools-new\gradle\gradle-4.0.1`
    
      Installed driver list:
    
      android: 2.0.36
      chrome: 1.0.6
      electron: 1.1.7 [out-of-date]
      ios: 2.0.22 [out-of-date]
    
    
    
    C:\Users\KingDow>app-inspector -v
    
     2.0.6
    
    
  • 你好 win10 遇到同样问题,请问你最后解决了吗?怎么解决的

  • 你好,辛苦帮忙看下 win10 启动 app-inspector 报错,以下是报错信息。

    Microsoft Windows [版本 10.0.15063]
    (c) 2017 Microsoft Corporation。保留所有权利。
    
    C:\Users\KingDow>adb devices -l
    List of devices attached
    192.168.189.101:5555   device product:vbox86p model:Genymotion__Phone__version device:vbox86p
    
    
    C:\Users\KingDow>app-inspector -u 192.168.189.101:5555
    { Error: Command failed: E:\autoTest\macaca\tools\android-sdk-windows/platform-tools/adb -s 192.168.189.101:5555 push C:\Users\KingDow\AppData\Roaming\npm\node_modules\app-inspector\node_modules\_uiautomatorwd@1.0.42@uiautomatorwd\app\build\outputs\apk\app-debug.apk /data/local/tmp/com.macaca.android.testing
    
        at ChildProcess.exithandler (child_process.js:270:12)
        at emitTwo (events.js:125:13)
        at ChildProcess.emit (events.js:213:7)
        at maybeClose (internal/child_process.js:921:16)
        at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
      killed: false,
      code: 1,
      signal: null,
      cmd: 'E:\\autoTest\\macaca\\tools\\android-sdk-windows/platform-tools/adb -s 192.168.189.101:5555 push C:\\Users\\KingDow\\AppData\\Roaming\\npm\\node_modules\\app-inspector\\node_modules\\_uiautomatorwd@1.0.42@uiautomatorwd\\app\\build\\outputs\\apk\\app-debug.apk /data/local/tmp/com.macaca.android.testing' }
    

    以下是软件的安装信息以及版本:

    Microsoft Windows [版本 10.0.15063]
    (c) 2017 Microsoft Corporation。保留所有权利。
    
    C:\Users\KingDow>macaca -v
    
      2.0.9
    
    
    C:\Users\KingDow>app-inspector -v
    
     2.0.6
    
    
    C:\Users\KingDow>macaca doctor
    
      macaca-doctor version: 2.0.2
    
    
      Node.js checklist:
    
      node env: C:\Program Files\nodejs\node.exe
      node version: v8.2.1
    
      Android checklist:
    
      JAVA version is `1.8.0_141`
      JAVA_HOME is set to `E:\WORKTOOLS\jdk\jdk-8u141-windows-x64`
      ANDROID_HOME is set to `E:\autoTest\macaca\tools\android-sdk-windows`
      Platforms is set to `E:\autoTest\macaca\tools\android-sdk-windows\platforms\android-22`
      ADB tool is set to `E:\autoTest\macaca\tools\android-sdk-windows\platform-tools\adb.exe`
      GRADLE_HOME is set to `E:\autoTest\macaca\tools-new\gradle\gradle-4.0.1`
    
      Installed driver list:
    
      android: 2.0.30 [out-of-date]
      chrome: 1.0.6
      electron: 1.1.7 [out-of-date]
      ios: 2.0.22 [out-of-date]
    
    C:\Users\KingDow>
    
  • 回复楼主 -- 首先非常感谢楼主整理的 macaca 非常详细的环境部署教程~~提出一点估计笔误的地方:安装 chromedriver 时命令有误:npm i macaca-chromedriver -g,看楼主截图中命令 dirver 有误,输入正确命令在淘宝源上是可以直接下载 chromedriver 的。