UIAutomation 在 iOS 6 中工作,但在 iOS 7 中不工作 (UIATarget.setLocationWithOptions)

Posted

技术标签:

【中文标题】UIAutomation 在 iOS 6 中工作,但在 iOS 7 中不工作 (UIATarget.setLocationWithOptions)【英文标题】:UIAutomation working in iOS 6 but not in iOS 7 (UIATarget.setLocationWithOptions) 【发布时间】:2013-10-01 11:54:18 【问题描述】:

我尝试为基于位置的应用程序编写 UIAutomation 测试。这是我的代码:

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.");

应用必须接收位置更新,如果一切正常,它会显示带有“已收到更新”文本的 UILabel。该测试在 ios 6 上运行,但在 iOS 7 上我没有收到位置更新。我在设备上进行了尝试,因为 target.delay(x) 方法在使用新 xcode 的模拟器中不起作用。 (我已经测试过了,它可以在旧的 xcode 版本中运行。)

谁能帮我在 iOS 7 上运行测试?有没有人面临同样的问题? (我计划编写更复杂的测试,但如果我没有收到位置更新,那么我就无法继续前进。)

谢谢

【问题讨论】:

我向 Apple 提交了一份雷达。 openradar.appspot.com/radar?id=4964878712307712 -- 雷达# 17838015 - 在 iOS 8 测试版中仍然无法使用。 在 8.0 SDK 的 Beta (3,4,5) 上试用它,但它不起作用。令人沮丧。 【参考方案1】:

我在这里遇到了同样的问题。 setLocation() 和 setLocationWithOptions() 方法在 iOS 7 上不起作用。在文档中 UIATarget 的所有方法(在 iOS 7 之前可用)都丢失了,并且在修订历史记录中没有这些更改的条目。

【讨论】:

以上是关于UIAutomation 在 iOS 6 中工作,但在 iOS 7 中不工作 (UIATarget.setLocationWithOptions)的主要内容,如果未能解决你的问题,请参考以下文章

为选定的 tableviewCell 的背景颜色设置框架在 iOS 7 中工作正常但在 iOS 6 中没有

添加 UITextField 作为 UITableViewCell 的子视图在 IOS 6 中工作正常,但在 IOS 7 中它不起作用?

无法让 RestKit 在 Xcode 4.6 中工作

iOS 7 缩放不能在具有 AutoLayout 的 ScrollView 中工作,但在 iOS8/9 中工作

尝试在具有 IOS 8 和 Xcode 6 UIAutomation 的设备上运行脚本时出错

让 Socket.io 在 Android Webview 中工作