简体   繁体   English

使用UIAutomation框架的iPhone App UI Automation?

[英]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 -: 我已经为这个按钮,无障碍标签isAccessible标志为好,我写了一个Java脚本来测试这个基本上打开了应用程序和水龙头这个按钮,这样我们就可以在应用移动到下一个页面,但问题是脚本无法点击按钮,我写的java脚本如下 - :

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" . 以上脚本似乎没有用,任何人都可以帮助我,每次我尝试使用仪器运行脚本,它说"Fail"

I don't believe that navigationItem is a function in UIAutomation. 我不相信navigationItem是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();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM