簡體   English   中英

如何使用Appium為Android Numpad輸入數值?

[英]How to enter numeric values to Android Numpad using Appium?

我嘗試過使用:

  1. send_keys方法:

driver.send_keys("12345678");

這不會給出任何錯誤,但甚至不輸入任何文本。

2.發送關鍵事件

HashMap numKeyObject = new HashMap();
numKeyObject.put("keycode", 145);
numKeyObject.put("keycode", 146);
numKeyObject.put("keycode", 147);
numKeyObject.put("keycode", 148);
numKeyObject.put("keycode", 149);
numKeyObject.put("keycode", 150);
((JavascriptExecutor ) driver).executeScript("mobile: keyevent", numKeyObject);

這給出了一個錯誤'org.openqa.selenium.WebDriverException:尚未實現'

我正在使用appium java client 2.2.0

以下是從android數字鍵盤輸入數值的方法

1) driver.sendkeyEvent(int key);

密鑰列表:a - z-> 29 - 54

“0” - “9” - > 7 - 16

BACK BUTTON - 4,MENU按鈕 - 82

UP-19,DOWN-20,LEFT-21,RIGHT-22

SELECT(MIDDLE)按鈕 - 23

空間 - 62,SHIFT - 59,ENTER - 66,BACKSPACE - 67

您可以在此處獲取密鑰代碼的說明: https//code.google.com/p/androhid/wiki/Keycodes

2)driver.findElementByID(“LocatorID”)。sendKeys(“123”);

請在評論中留下問題

嘗試這樣做:

driver.findElementByID("locator").sendKeys("");
The best and easier way is :

element.setValue("");

for eg:
@AndroidFindBy(id = "com.android.life.login:id/et_pin")
private MobileElement unlockPhone;
public void unlockPhone() {
    unlockPhone.setValue("1111");
    System.out.println("Lockscreen Unlocled");
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM