如何检测iOS9 9/XCode7 7 SKScene功能中的当前UItesting?
我尝试将SKScene的SKScene设置为SKScene的init方法中的标识符字符串,但这似乎没有显示在用户界面测试中。
XCUIElement *element =
[[[_app childrenMatchingType:XCUIElementTypeWindow] elementBoundByIndex:0]
childrenMatchingType:XCUIElementTypeOther].element;通过添加UILabel,通过部分工作的黑客更新问题,如下所示:
我将以下代码添加到我的SKScene中
-(void)didMoveToView:(SKView *)view
{
// This is not detected by the test case.
self.accessibilityLabel = @"SceneMenu";
self.accessibilityValue = @"anything";
self.isAccessibilityElement = true;
// This is detected by the test case.
self.currentScene = [[UILabel alloc] initWithFrame:CGRectMake(0, 20, self.size.width, 25)];
[self.view addSubview:_currentScene];
self.currentScene.accessibilityLabel = @"SceneMenu2";
}然后,我可以在我的UI测试用例中检测到"SceneMenu2“,但是我不能检测到"SceneMenu”。怎么会这样?这是我的测试用例:
-(bool)sceneMenuIsShown
{
return [_app.otherElements containingType:XCUIElementTypeStaticText identifier:@"SceneMenu2"].count == 1;
}
- (void)testExample
{
while (![self sceneMenuIsShown])
{
}
}发布于 2015-11-08 11:51:36
目前这是不可能的(据苹果员工)。https://forums.developer.apple.com/thread/25019
https://stackoverflow.com/questions/33483046
复制相似问题