Sendkeys 在 android appium 驱动程序上失败
我正在使用 appium 来自动化 android 应用程序.在这种情况下,无法对以下情况的文本字段执行 sendkeys():单击添加客户选项.打开一个新页面.我正在尝试在文本字段中输入值.我能够使用 xpath 在页面上找到文本字段.我能够点击文本字段.但是当我执行 sendkeys() 时,它失败了.请参阅以下屏幕截图.
链接:1-添加客户之前(第1页)
Link:1-Before adding customer(page-1)
链接:2-添加客户-打开新页面(第2页)并尝试输入详细信息
Link:2-Add customer-New page opened(page-2) and trying to enter details
链接:3-关闭打开的页面(第 2 页)并登陆第 1 页后
Link:3-After closing the page opened(page-2) and landing on page-1
我可以通过 AppiumDriver.sendKeyEvent(int key) 在 android 键盘上键入来将键发送到 android 文本字段:
I can send keys to the android text field, by typing on android keyboard with AppiumDriver.sendKeyEvent(int key):
driver.findElement(locator).click();
driver.sendKeyEvent(29); // android key event code for letter 'a', look up key code at
// android.view.KeyEvent library
driver.hideKeyboard();
您可以使用循环以这种方式使用 android 键盘发送字符串的所有字符.要么使用 android.view.KeyEvent 要么自己将字符转换为键码(int)
You can use a loop to send all characters of your string using the android key board this way. Either use android.view.KeyEvent or convert character to key code (int) yourself