Madhu
Madhu

Reputation: 11

How to enter the text in search bar using UIAutomation?

Could you please help me out in entering the text in search bar using UIAutomation scripts for IPhone Application.

Thanks in advance, Madhu.

Upvotes: 1

Views: 3084

Answers (2)

John Doe
John Doe

Reputation: 4592

Since through tap input method you communicate with the device, you can try user-like type of action: tapping.

To bring up the keyboard you just tap on the text input field:

someTextInputField.tap();

But be aware of the fact that there is no keyboard object instance available for actions if you do not activate the keyboard itself by tapping on any text input field.

Once the keyboard is activated:

var App = UIATarget.localTarget().frontMostApp();
var Keyboard = App.keyboard();
var Keys = Keyboard.keys();
var AltKeys = Keyboard.buttons();

Where AltKeys represent service buttons like Shift, Done, etc. And Keys represent all other buttons.

P.S. Keep in mind that you have to switch between keyboard tabs to get access to either characters, numbers, special characters.

Upvotes: 0

vievievie
vievievie

Reputation: 338

UIASearchBar inherits from UIATextField:

http://developer.apple.com/library/ios/#documentation/ToolsLanguages/Reference/UIASearchBarClassReference/UIASearchBar/UIASearchBar.html#//apple_ref/doc/uid/TP40009913

Try the "setValue" method:

searchBar.setValue("search for this");

Upvotes: 4

Related Questions