Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS Instruments Automation "setValue" not working

I just want to test my iOS UI with UI Automation but I got stuck when it comes to enter text into UITextFields. The documentation says that the method "setValue(...)" should do the trick but it doesn't.

I always get this error:

Script threw an uncaught JavaScript error: Unexpected error in -[UIATextField_0x9952690 setValue:], /SourceCache/UIAutomation_Sim/UIAutomation-271/Framework/UIAElement.m line 1142, kAXErrorSuccess on line 15 of login.js, #0 setValue() 

The code looks like this:

var textfields = UIATarget.localTarget().frontMostApp().mainWindow().textFields();
username = textfields["username"];
username.setValue("test");

The username field is not null or undefined.

My second solution was this JS project: https://github.com/alexvollmer/tuneup_js#readme It has a "typeString" method for text fields but it is a little bit buggy and fails when it comes to enter numbers and capital letters.

I'm working with iOS6.1, Instruments Version 4.6 (46000), Xcode Version 4.6 (4H127).

Any help is appreciated!

like image 963
ralphbert Avatar asked Feb 13 '13 15:02

ralphbert


1 Answers

Check if below works for you,

target.delay(1); UIATarget.localTarget().frontMostApp().mainWindow().textFields()["username"].tap(); target.delay(1); UIATarget.localTarget().frontMostApp().mainWindow().textFields()["username"].setValue("test");

Check for correct hierarchy if it does not work for you..

like image 99
San27 Avatar answered Oct 02 '22 07:10

San27