简体   繁体   中英

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.
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 ie digits(1,2,3,4,5,6,7,8,9,0) etc.

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")

    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. 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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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