Reputation: 723
I am testing an iOS app in the simulator from the keyboard and would like for the keyboard return key to make a button on the screen be pressed. Is there a way to do this? I can move between UITextField's with the Tab key and capture the Return key through the textFieldShouldReturn method, but I have a submit button on the page also and would like to cruise through it without going to the mouse by firing it from the keyboard. If there is a way to move the focus to the button so that I can use a space-bar as suggested by KevinDTimm that would be great. Although I can move the focus through the UITextFields with the tab key I am just not sure how to get the focus onto the button - tab is not working at this point.
Thanks in advance
Upvotes: 0
Views: 956
Reputation: 7513
From what I understand you effectively want to do an automated UI test. But in this case "you" are the automation. Thinking about it that way lead me to ios-automated-tests-with-uiautomation which may not solve your problem directly, but may be the path you should head down.
This blog references Apples UI Automation Reference Collection which states:
Use the UI Automation feature to write test scripts that exercise your app’s user interface elements as it runs on a connected device. You write the tests in JavaScript, calling the UI Automation API to simulate user interaction. The system returns log information to the host computer.
Upvotes: 2
Reputation: 89232
If focus was on the button, the keyboard would go away. You captured the Return, why not just call the action associated with the button?
EDIT: Try it on your phone with a Bluetooth connected keyboard. Do you get the events then? I think the simulator just uses the keyboard as a way to use the virtual keyboard, not like a bluetooth connected one.
Upvotes: 0
Reputation: 14376
IIRC, the space bar works when you're on a button on the iOS simulator
Upvotes: 0