简体   繁体   English

如何使用Appium在python脚本中的android app中使用移动键盘输入数值

[英]How to enter numeric values using mobile keypad in android app in python script using Appium

I am writing a python script to automate android application. 我正在编写一个python脚本来自动化android应用程序。
I want to enter values in text board using mobile keypad . 我想使用移动keypad在文本板上输入值。

I was able to enter the value in text field using send_keys , but in some cases I have to enter values using android keypad ie digits(1,2,3,4,5,6,7,8,9,0) etc. 我能够使用send_keys在文本字段中输入值,但在某些情况下,我必须使用android小键盘输入值,即digits(1,2,3,4,5,6,7,8,9,0)等。

Can anyone tell me how to enter these value using keypad? 谁能告诉我如何使用键盘输入这些值?

try this emailSign = self.driver.find_element_by_class_name("UIATextField") passSign = self.driver.find_element_by_class_name("UIASecureTextField") 试试这个emailSign = self.driver.find_element_by_class_name(“ UIATextField”)passSign = self.driver.find_element_by_class_name(“ UIASecureTextField”)

    passSign.click()

    emailSign.send_keys(username + carriage_return)
    passSign.send_keys(password + carriage_return)

I'm not quite sure what you're trying to do here, but you can send keystrokes with selenium: 我不太确定您要在这里做什么,但是您可以发送带有硒的击键:

from selenium.webdriver.common import keys
textfield.send_keys(keys.Keys().ENTER)

Where 'textfield' is your text field element. 其中“ textfield”是您的文本字段元素。 If you look at the Keys class in selenium, you can send any of the keyboard keys. 如果您查看硒中的Keys类,则可以发送任何键盘键。 This is useful if you want to hide the keyboard - just send a tab key and it will focus elsewhere. 如果您想隐藏键盘,这将很有用-只需发送一个Tab键,它将集中在其他位置。

Not sure about Python, but this is how I overcome a similar issue from a Java client code. 不确定Python,但这是我如何克服Java客户端代码中的类似问题的方法。

AndroidDriver driver;
//... then setup driver

//... put some text on target text field
textfield.click();
textfield.sendKeys("some content");

//... finally send Enter key
driver.sendKeyEvent(AndroidKeyCode.ENTER);

Check if the Python API offers such enumeration. 检查Python API是否提供此类枚举。 Hope this helps. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM