AnkitSablok
AnkitSablok

Reputation: 3159

iPhone App UI Automation using the UIAutomation framework?

Hi people I have a serious problem at hand, I have taken a navigation bar controller in my application and inside that bar I have a right button the code for which is written as follows -:

    UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] init];
    rightButton.action = @selector(loadLeaseView);
    rightButton.target = self;
    rightButton.title = @"Next";
    rightButton.style = UIButtonTypeDetailDisclosure;
    rightButton.isAccessibilityElement = YES;
    rightButton.accessibilityLabel = @"Next";

    self.navigationItem.leftBarButtonItem = nil;
    self.navigationItem.hidesBackButton = YES;
    self.navigationItem.rightBarButtonItem  = rightButton;
    [rightButton release];  

I have set the accessibility label for this button and isAccessible flags as well, and I have written a java script to test this which basically opens up the app and taps this button so that we can move to next page in the app, but the problem is that the script is not able to tap the button, the java script I wrote is as follows -:

UIALogger.logStart("Starting Test");
var target = UIATarget.localTarget().frontMostApp().mainWindow();
var navBar = target.navigationBar().navigationItem();

var button = navBar.rightButton();
button.tap();

the above script doesn't seem to work can anyone please help me out, everytime I try to run the script using instruments it says "Fail".

Upvotes: 0

Views: 676

Answers (1)

011
011

Reputation: 81

I don't believe that navigationItem is a function in UIAutomation.

I think what you're looking for is something more like …

var target = UIATarget.localTarget();
var app = target.app = target.frontMostApp();
var navBar = app.mainWindow().navigationBar();
var button = navBar.rightButton(); 
button.tap();

Upvotes: 2

Related Questions