0

我的自动化框架中有以下代码片段

 public void settings() {
        try {
            //((AndroidDriver) Driver).pressKeyCode(AndroidKeyCode.SETTINGS);
            ((AndroidDriver) Driver).pressKey(new KeyEvent(AndroidKey.SETTINGS));
            updateTestLog(Action, "settings pressed", Status.PASS);
        } catch (Exception ex) {
            updateTestLog(Action, ex.getMessage(), Status.DEBUG);
            Logger.getLogger(KeyActions.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

我已经连接了手机,看看它是否工作正常。在 Appium 服务器中获得了密钥代码 176(设置)工作正常的日志跟踪。但是在手机屏幕上没有动作

我已经尝试过不同的键,如“菜单”、“主页”、“搜索”和“输入”。我看到它在移动设备中执行并运行良好。

4

1 回答 1

1

如果您需要打开设置菜单,我相信最好的选择是调用driver.startActivity()函数,例如:

((AndroidDriver) driver).startActivity(new io.appium.java_client.android.Activity("com.android.settings",".Settings"));

如果您正在寻找跨平台解决方案,则通过SeeTest Appium Extension获取Launch 命令可能更容易

于 2019-08-21T13:51:36.650 回答