小编nsc*_*hum的帖子

从iOS UIAutomation发出JavaScript中的同步HTTP GET请求或调用shell脚本

我正在尝试使用Apple的UIAutomation为具有服务器端组件的iOS应用程序编写单元测试.为了在各种状态下设置测试服务器(以及模拟通过我的服务器进行通信的两个客户端),我想在基于javascript的测试中发出HTTP get请求.

任何人都可以提供一个示例,说明如何直接从UIAutomation javascript测试中发出HTTP GET请求,或者如何从我的UIAutomation javascript测试中调用shell脚本?

FWIW,UIAutomation运行时中缺少所有浏览器提供的大多数核心对象.例如,尝试使用XMLHTTPRequest,您将收到一个异常报告,它无法找到该变量.

谢谢!

javascript iphone integration-testing ios ios-ui-automation

7
推荐指数
2
解决办法
2313
查看次数

iOS UIAutomation:访问自动化脚本中UIScrollView上添加的自定义子视图

我是iOS UIAutomation的新手,这是我面临的问题

我有一个视图层次结构如下所示,并希望访问自动化sctipt中的CustomView2元素

UIWindow> UIScrollView> CustomView1(多个)> CustomView2(多个)

scrollview具有CustomView1类型的子视图,而CustomView1又具有CustomView2类型的子视图.

我已将可访问性信息分配给层次结构中的所有视图,但我无法访问自动化脚本中的CustomView2元素.

当我在UIScrollView上执行logElementTree()时,我得到的只是CustomView2的实例,而CustomView2甚至不在UIWindow的树结构中.

请建议是否有任何遗漏或出现任何问题.

这是我正在使用的代码

var mainWindow = application.mainWindow();
var scrollView = mainWindow.scrollViews()[0];
var custom1 = scrollView.elements().withName("CustomView1");

for(var index=0; index<custom1.length; index++){
    currentIndustry.tap();
    custom1[index].logElementTree();
    var custom2 = custom1[index].elements().withName("CustomView2");
    UIALogger.logPass("Custom2 Length : " + custom2.length);
}
Run Code Online (Sandbox Code Playgroud)

由custom1 [index] .logElementTree()打印的树; 不包含CustomView2的实例

PS我需要访问CustomView1和CustomView2元素

scrollview ios ios-ui-automation

6
推荐指数
1
解决办法
2892
查看次数

UIAutomation脚本示例

有没有人在带有示例项目的UIAutomation测试脚本上找到任何示例?到目前为止,我发现只有WWDC2010视频涵盖了这个主题,但没有样本脚本/项目可以使用.

在Xcode/Instruments中编辑脚本时,有没有办法实现代码建议/自动完成?

iphone xcode instruments ios ios-ui-automation

6
推荐指数
1
解决办法
1314
查看次数

由于Swift模式匹配中的顺序导致意外结果

对不起,"这不应该工作吗?" 题.但我无法想出一个更好的方式来表达这一点.

enum MyEnum {
    case A, B, C
}

let tuple = (MyEnum.C, MyEnum.A)    
var x: String

switch tuple {
case (.A, _):
    x = "(A, something)"
case (_, .A):
    x = "(something, A)"
case (_, .B):
    x = "(something, B)"
case (.C, .C):
    x = "(C, C)"
default:
    x = "default"
}

x // -> "default"
Run Code Online (Sandbox Code Playgroud)

x求值为"default",表示采用了默认分支.

但是,我期待"(something, A)"和第二个案例陈述相匹配.根据我的理解,(_, .A)应该匹配第一个元组元素和.A第二个元素中的任何内容.

如果我将(_, .A)表壳移到顶部,它会按照我的预期进行匹配.其他元组也匹配我期望的位置.

我错过了什么?为什么这不符合第二种情况?

pattern-matching swift

6
推荐指数
1
解决办法
870
查看次数

通用iOS应用程序中的单独设置?

我正在开发一个通用的iOS应用程序,但是一些用户设置在iPad上没那么明显.

我可以在iPad上指定单独的Settings.bundle或Root.plist吗?

iphone nsuserdefaults universal ipad ios

5
推荐指数
1
解决办法
1559
查看次数

iOS UIAutomation:是否可以将屏幕截图与参考图像进行比较?

标题已经解释了.我正在寻找一种解决方案,将UIAutomation脚本中使用target.captureScreenWithName拍摄的屏幕截图与一些参考图像进行比较.这对测试一些自定义视图非常好.

iphone cocoa-touch ios ios-ui-automation

5
推荐指数
1
解决办法
2361
查看次数

缩进Xcode中的连续行

我可以使用Xcode的自动缩进来缩进延续线吗?

我想要:

BOOL someLongVariableName = someLongValue
    | someOtherLongValue
    | moreLongValues

BOOL someOtherLongVariableName =
    someEvenLongerValue;

[someLongVariableName
    performSomeAction:someLongArgument]
Run Code Online (Sandbox Code Playgroud)

我目前得到:

BOOL someLongVariableName = someLongValue
| someOtherLongValue
| moreLongValues

BOOL someOtherLongVariableName =
someEvenLongerValue;

[someLongVariableName
 performSomeAction:someLongArgument]
Run Code Online (Sandbox Code Playgroud)

要明确:

  • 我使用显式换行而不是自动换行.
  • 我希望在编辑时和按下返回后立即缩进,而不是在运行外部程序(如uncrustify)之后.

xcode indentation

5
推荐指数
1
解决办法
1381
查看次数

为什么我的视图中的按钮不能被UIAutomation看到?

我能够看到视图,但我无法看到/点击其中的按钮.该按钮具有UIA_loginview_loginbutton的辅助功能标签,并且启用了辅助功能.为什么它没有显示在logElementTree()上?

var target = UIATarget.localTarget();
var application = target.frontMostApp();
var window = application.mainWindow(); 
var view = window.elements().firstWithName("UIA_loginview_view"); 


UIATarget.localTarget().logElementTree();
UIATarget.localTarget().frontMostApp().logElementTree();


if(view == null || view.toString() == "[object UIAElementNil]") 
{
UIALogger.logFail("View not found - "+view.toString());
} 
else
{
    UIALogger.logPass("View found - "+view.toString());
    UIALogger.logMessage("View Elements length - "+view.buttons().length);
    view.buttons()["UIA_loginview_loginbutton"].tap();
}
Run Code Online (Sandbox Code Playgroud)

日志元素树://显示我的视图,但不显示其中的按钮

4)UIAElement [name:UIA_loginview_view value:(null)NSRect:{{0,20},{320,460}}]

iphone ios ios-ui-automation

5
推荐指数
1
解决办法
1946
查看次数

UIAutomation iPhone:是否可以将脚本分成几个文件

我想为一个相当复杂的iPhone应用程序编写UIAutomation(基于JavaScript)测试.我不想使用一个单独的大文件,而是通过使用几个文件来分离测试函数和帮助程序.这有可能吗?你如何构建你的UIAutomation测试?

javascript iphone ios-ui-automation

5
推荐指数
1
解决办法
1518
查看次数

为什么我不能使用UI Automation脚本访问iPhone应用程序中的Back按钮?

我有一个简单的函数,应该检查视图是否在home接口,如果没有,将它带到家里:

function returnHome() {
    if (UIATarget.localTarget().frontMostApp().navigationBar().name() == mainTitle) return true;

    // set tab bar to calculations
    UIALogger.logMessage("Set tab bar to main.");
    if (UIATarget.localTarget().frontMostApp().tabBar().selectedButton().name() != mainTabName) {
        UIATarget.localTarget().frontMostApp().tabBar().buttons()[mainTabName].tap();
    }

    // go back to the home
    UIALogger.logMessage("Go back to home.");
    var backButton = UIATarget.localTarget().frontMostApp().mainWindow().buttons()["Back"];
    if (backButton.isValid()) {
        backButton.tap();
    } else {
        UIALogger.logError("Could not find 'Back' button!");
    }
}
Run Code Online (Sandbox Code Playgroud)

现在,我无法通过错误"无法找到'返回'按钮!".它在那里,在左角,盯着我,嘲弄我!

UIATarget.localTarget().frontMostApp().logElementTree()给了我下面的树:

2) UIAApplication [name:MyApplication value:(null) rect:{{x:0, y:20}, {width:320, height:460}}]
3) UIAWindow [name:(null) value:(null) rect:{{x:0, y:0}, {width:320, height:480}}]
4) UIAImage [name:(null) value:(null) …
Run Code Online (Sandbox Code Playgroud)

iphone xcode cocoa-touch instruments ios-ui-automation

4
推荐指数
1
解决办法
3841
查看次数