如何使用键盘操作Appium Android按绿色tick按钮

发布于 2025-02-11 18:04:59 字数 1030 浏览 1 评论 0 原文

在我的代码中,我需要按一些数字,然后单击“绿色勾号”按钮。

单击后,预期是隐藏键盘,并显示错误验证消息。

“在此处输入图像说明”

我在脚本中具有以下代码。

    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_2));
    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_3));
    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_4));
    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.ENTER));

根据代码。它进入值。不确定要通过哪个androidkey按下绿色tick按钮,我通过Androidkey.enter。它提供了不同的行为,并手动按Enter Enter提供相同的行为。

任何人都可以告诉他如何通过Androidkey参数,因此按下绿色tick键。 绝对不是进入。

In my code, I need to press some number and click on green tick button.

enter image description here

After I click, expected is hide the keypad and it shows a error validation message..

enter image description here

I have the following code in my script.

    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_2));
    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_3));
    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_4));
    ((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.ENTER));

As per code. Its entering the value. Not sure which AndroidKey to pass for pressing Green tick button, I'm passing AndroidKey.ENTER. It gives a different behavior and manually also pressing enter give same behavior.

enter image description here

Can any one tell him how to pass AndroidKey parameter, so it press the green tick key.
It's definitely not ENTER.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

转身以后 2025-02-18 18:04:59
<EditText
android:id="@+id/edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="fintme"
android:inputType="text"
android:imeOptions="actionSend" />

EditText editText = (EditText) findViewById(R.id.edittext);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    boolean handled = false;
    if (actionId == EditorInfo.IME_ACTION_SEND) {
        //yourcode
        handled = true;
    }
    return handled;
  }
});
<EditText
android:id="@+id/edittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="fintme"
android:inputType="text"
android:imeOptions="actionSend" />

EditText editText = (EditText) findViewById(R.id.edittext);
editText.setOnEditorActionListener(new OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    boolean handled = false;
    if (actionId == EditorInfo.IME_ACTION_SEND) {
        //yourcode
        handled = true;
    }
    return handled;
  }
});
初吻给了烟 2025-02-18 18:04:59

我从以下解决方案的其他组中找到了。

driver.executescript(“移动:performeditorAction”,immutableMap.of(“ action”,“ go”));

支持的其他选项列表可以在以下站点中找到:

https://appium.io/文档/EN/写作 - 录取/android/android-ime/


当我们可见键盘时,单击后按钮也隐藏了键盘,并显示屏幕。

((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_2));
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_3));
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_4));
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.BACK));

I found from other groups below solutions.

driver.executeScript(“mobile: performEditorAction”, ImmutableMap.of(“action”, “Go”));

List of other options supported can be found in below sites:
https://developer.android.com/reference/android/view/inputmethod/EditorInfo

https://appium.io/docs/en/writing-running-appium/android/android-ime/

Also,
When we have keypad visible, clicking on BACK button also hides the keyboard and it shows the screen.

((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_2));
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_3));
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.DIGIT_4));
((AndroidDriver) driver).pressKey(new KeyEvent(AndroidKey.BACK));
放血 2025-02-18 18:04:59

请使用10位数字的有效手机号码,因为这似乎可以在移动应用程序上进行验证。

您的脚本还不错,除了输入有效的手机号码,使用您的自动化脚本。

另外,请首先检查任何有效的手机号码,然后使用您的自动化脚本输入相同的手机号码,这应该解决您的问题。

Please use valid mobile number of 10 digits as this seems to be get validated on mobile app.

Your script is fine except entering a valid mobile number with your automation script.

Also, please check first manually any valid mobile number and then input the same mobile number with your automation script, this should resolve your issue then.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文