3

I try to write UIAutomation test for a location based app. Here is my code:

var target = UIATarget.localTarget();
var mainWindow = target.frontMostApp().mainWindow();  

// speed is in meters/sec 
var points = [
    {"location":{"latitude":46.783959176435,"longitude":23.542576152853}, "options":{"speed":32.33869934082}},
    {"location":{"latitude":46.784235069873,"longitude":23.542993452429}, "options":{"speed":33.44660949707}},
    {"location":{"latitude":46.784323173489,"longitude":23.543161503691}, "options":{"speed":33.76908493042}},
    {"location":{"latitude":46.784514430638,"longitude":23.54344429169}, "options":{"speed":34.434867858887}},
    {"location":{"latitude":46.784609053263,"longitude":23.543600872392}, "options":{"speed":34.673755645752}},
    {"location":{"latitude":46.784701914083,"longitude":23.54376055256}, "options":{"speed":34.920608520508}},
    {"location":{"latitude":46.784792299278,"longitude":23.543917345257}, "options":{"speed":34.939456939697}},
    {"location":{"latitude":46.784869569202,"longitude":23.54409146343}, "options":{"speed":34.837844848633}},
    {"location":{"latitude":46.784959115698,"longitude":23.544272081608}, "options":{"speed":34.80908203125}},
    {"location":{"latitude":46.785085476228,"longitude":23.544603009802}, "options":{"speed":34.722270965576}},
    {"location":{"latitude":46.785085476228,"longitude":23.544603009802}, "options":{"speed":0.0}}
];

var driveDetectionStarted;
for (var i = 0; i < points.length; i++){
    target.setLocationWithOptions(points[i].location,points[i].options); // send location update
    target.delay(0.2); // sleep until next location update
}

target.delay(1);
if (mainWindow.staticTexts()[0].value() == "Updates Received") {
    driveDetectionStarted = true;
}
if (driveDetectionStarted) {
    UIALogger.logPass("Location updates received as expected.");
} else {
    UIALogger.logFail("Location updates logic failed.");
}

The app has to receive location updates, and if everything is okay, then it will display a UILabel with the "Updates Received" text. This test is working on iOS 6, but I don't receive location updates on iOS 7. I tried on devices, since the target.delay(x) method doesn't work in the simulator with the new xcode. (I've tested, and it was working in the old xcode version.)

Can anyone help me out to run the test on iOS 7? Does anyone face the same problem? (I plan to write more complex tests, but if I don't receive location updates, then I simple can't move on.)

bad_coder
  • 11,289
  • 20
  • 44
  • 72
Zootyo
  • 150
  • 1
  • 7

1 Answers1

2

I am having the same problem here. The setLocation() and setLocationWithOptions() methods are not working on iOS 7. In the documentation all methods for UIATarget (which were available before iOS 7) are missing and there is no entry for these changes in the revision history.

Julianddc
  • 21
  • 1