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

不想你离开。 提交于 2019-12-24 11:37:45

问题


I am writing a python script to automate android application.
I want to enter values in text board using mobile 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 i.e digits(1,2,3,4,5,6,7,8,9,0) etc.

Can anyone tell me how to enter these value using keypad?


回答1:


try this 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)



回答2:


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. If you look at the Keys class in selenium, you can send any of the keyboard keys. This is useful if you want to hide the keyboard - just send a tab key and it will focus elsewhere.




回答3:


Not sure about Python, but this is how I overcome a similar issue from a Java client code.

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. Hope this helps.



来源:https://stackoverflow.com/questions/27898661/how-to-enter-numeric-values-using-mobile-keypad-in-android-app-in-python-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!