Archive for the 'UIAutomation' Category

Swipe gesture in UIAutomation

Wednesday, March 23rd, 2011

It took me a while to figure this out, but the key is that in your gesture coordinates, the values cannot result in a perfect translation left to right (and presumable up and down, but I didn’t test a vertical gesture.)

I use a horizontal swipe gesture on the navigationBar to bring up an alert that contains diagnostic information.

// Boiler plate code. var target = UIATarget.localTarget(); var application = target.frontMostApp(); var mainWindow = application.mainWindow(); // Swipe gesture to bring up console. var navigationBar = mainWindow.navigationBar(); navigationBar.dragInsideWithOptions({startOffset:{x:0.0, y:0.0}, endOffset:{x:0.8, y:0.10}, duration:0.1});

Reference: wiki

UIAutomation ‘typing’ on the keyboard

Monday, March 21st, 2011

I was looking for a way to use the iOS keyboard directly, Stack oveflow to the rescue again:

// Boiler plate code. var target = UIATarget.localTarget(); var application = target.frontMostApp(); var mainWindow = application.mainWindow(); var keyBoard=application.keyboard(); var keys = keyBoard.keys(); keys.firstWithName("g").tap(); target.delay(0.5); keys.firstWithName("o").tap(); target.delay(0.5); keys.firstWithName("r").tap(); target.delay(0.5); keys.firstWithName("d").tap(); target.delay(0.5); keys.firstWithName("o").tap(); target.delay(0.5);

Reference: stackoverflow wiki