2016-11-08 55 views
0

我正在尝试为我的应用程序编写UI测试。我有一个弹出窗口,它是一个带有UITableView的模态表示视图控制器。该tableview包含2个可点击的单元格,两者都关闭视图控制器。问题是出现这个弹出窗口时,它显示为我的元素树中的“其他元素”,而不是视图控制器。我可以找到与otherElements[@"PopOverViewController"]的元素,但我无法点击控制器上的单元格,因为它不知道它们是什么。iOS UI测试 - 呈现的视图控制器显示为“其他元素”

→Other 0x7fc778039540: traits: 8589934592, {{32.0, 155.5}, {311.0, 356.0}}, label: 'PopOverViewController' 

如何访问此元素并单击此视图控制器上的按钮?

由于

EDIT

下面是当PopOverViewController是显示

Image 0x7fc26378c270: traits: 8589934596 
    Image 0x7fc263784310: traits: 8589934596, {{0.0, 0.0}, {375.0, 64.0}} 
    Button 0x7fc263786ff0: traits: 8724152321, {{8.0, 26.0}, {110.0, 30.0}}, label: '*****' 
    Button 0x7fc26378d480: traits: 8724152321, {{8.0, 36.5}, {11.0, 11.0}}, label: '*****' 
    StaticText 0x7fc263794620: traits: 8589934656 
    StaticText 0x7fc2637817d0: traits: 8590000192 
    NavigationBar 0x7fc263788140: traits: 35192962023424, {{0.0, 20.0}, {375.0, 44.0}}, identifier: '*****' 
    StaticText 0x7fc263793090: traits: 8589934656, {{146.5, 70.5}, {82.0, 22.0}}, label: '*****' 
    Button 0x7fc26378ea40: traits: 8589934593, {{67.5, 104.5}, {240.0, 35.0}}, label: '*****' 
    StaticText 0x7fc26378de50: traits: 8589934656, {{86.0, 155.5}, {203.5, 38.5}}, label: '*****' 
    Other 0x7fc263795f30: traits: 8589934592, {{67.5, 54.0}, {240.0, 168.0}} 
    Other 0x7fc26379b470: traits: 8589934592 
    Other 0x7fc26379a570: traits: 8589934592, {{0.0, 64.0}, {375.0, 148.0}} 
    Other 0x7fc26378f9c0: traits: 8589934592, {{0.0, 216.0}, {375.0, 407.0}} 
    StaticText 0x7fc26379be90: traits: 8589934656, {{90.0, 232.0}, {53.5, 20.5}}, label: '*****' 
    StaticText 0x7fc26379c4f0: traits: 8589934656, {{90.0, 250.0}, {114.0, 19.5}}, label: '*****' 
    StaticText 0x7fc26379cd60: traits: 8589934656, {{90.0, 289.0}, {57.0, 18.0}}, label: '*****' 
    Cell 0x7fc2637934c0: traits: 8589934592, {{0.0, 216.0}, {375.0, 123.0}} 
    StaticText 0x7fc26379dc10: traits: 8589934656, {{90.0, 355.0}, {52.5, 20.5}}, label: '*****' 
    StaticText 0x7fc26379e330: traits: 8589934656, {{90.0, 373.0}, {98.0, 19.5}}, label: '*****' 
    StaticText 0x7fc26379ea80: traits: 8589934656, {{90.0, 412.0}, {57.0, 18.0}}, label: '*****' 
    Cell 0x7fc26379d490: traits: 8589934592, {{0.0, 339.0}, {375.0, 123.0}} 
    StaticText 0x7fc26379f970: traits: 8589934656, {{90.0, 478.0}, {95.0, 20.5}}, label: '*****' 
    StaticText 0x7fc2637a00b0: traits: 8589934656, {{90.0, 496.0}, {129.5, 19.5}}, label: '*****' 
    StaticText 0x7fc2637a0800: traits: 8589934656, {{90.0, 535.0}, {57.0, 18.0}}, label: '*****' 
    Cell 0x7fc26379f1f0: traits: 8589934592, {{0.0, 462.0}, {375.0, 123.0}} 
    Table 0x7fc2637901b0: traits: 35192962023424, {{0.0, 64.0}, {375.0, 559.0}} 
    Button 0x7fc2637a0ff0: traits: 8589934593, {{0.0, 623.0}, {375.0, 44.0}}, label: '*****' 
    Other 0x7fc2637a1710: traits: 8589934592 
    Other 0x7fc263796ea0: traits: 8589934592, {{0.0, 64.0}, {375.0, 603.0}} 
    Other 0x7fc263799490: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc263791ac0: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc26376a060: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}} 
    Image 0x7fc2637a26a0: traits: 4, {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc2637a2de0: {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc2637a3500: traits: 8589934592, {{32.0, 155.5}, {311.0, 356.0}}, label: 'PopOverViewController' 
    Other 0x7fc2637a1f50: {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc263782e40: {{0.0, 0.0}, {375.0, 667.0}} 
    Window 0x7fc263112950: Main Window, {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc2637a4cc0: traits: 8589934592 
    Other 0x7fc2637a44d0: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}} 
    Window 0x7fc2637a3d50: {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc2637a6340: {{0.0, 0.0}, {375.0, 20.0}} 
    Other 0x7fc2637a7210: traits: 8388608, {{6.0, 0.0}, {39.0, 20.0}} 
    Other 0x7fc2637a7960: traits: 8388608, {{50.0, 0.0}, {13.0, 20.0}}, label: '3 of 3 Wi-Fi bars', value: SSID 
    Other 0x7fc2637a80e0: traits: 8389120, {{165.0, 0.0}, {48.0, 20.0}}, label: '1:29 PM' 
    Other 0x7fc2637a8850: traits: 8388608, {{345.0, 0.0}, {25.0, 20.0}}, label: '-100% battery power' 
    Other 0x7fc2637a6a90: {{0.0, 0.0}, {375.0, 20.0}} 
    StatusBar 0x7fc2637a5bd0: {{0.0, 0.0}, {375.0, 20.0}} 
    Window 0x7fc2637a5450: {{0.0, 0.0}, {375.0, 667.0}} 

我可以看到PopOverViewController但没有一个文本或单元的在其上(文本被消隐的输出但是来自呈现视图控制器,而不是视图控制器上弹出的内容)

编辑

如果我跑[app.otherElements[@"PopOverViewController"] descendantsMatchingType:XCUIElementTypeAny]我看到输出:

Other 0x7fc263795f30: traits: 8589934592, {{67.5, 54.0}, {240.0, 168.0}} 
    Other 0x7fc26379b470: traits: 8589934592 
    Other 0x7fc26379a570: traits: 8589934592, {{0.0, 64.0}, {375.0, 148.0}} 
    Other 0x7fc26378f9c0: traits: 8589934592, {{0.0, 216.0}, {375.0, 407.0}} 
    Other 0x7fc2637a1710: traits: 8589934592 
    Other 0x7fc263796ea0: traits: 8589934592, {{0.0, 64.0}, {375.0, 603.0}} 
    Other 0x7fc263799490: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc263791ac0: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc26376a060: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc2637a2de0: {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc2637a3500: traits: 8589934592, {{32.0, 155.5}, {311.0, 356.0}}, label: 'PopOverViewController' 
    Other 0x7fc2637a1f50: {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc263782e40: {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc2637a4cc0: traits: 8589934592 
    Other 0x7fc2637a44d0: traits: 8589934592, {{0.0, 0.0}, {375.0, 667.0}} 
    Other 0x7fc2637a6340: {{0.0, 0.0}, {375.0, 20.0}} 
    Other 0x7fc2637a7210: traits: 8388608, {{6.0, 0.0}, {39.0, 20.0}} 
    Other 0x7fc2637a7960: traits: 8388608, {{50.0, 0.0}, {13.0, 20.0}}, label: '3 of 3 Wi-Fi bars', value: SSID 
    Other 0x7fc2637a80e0: traits: 8389120, {{165.0, 0.0}, {48.0, 20.0}}, label: '1:29 PM' 
    Other 0x7fc2637a8850: traits: 8388608, {{345.0, 0.0}, {25.0, 20.0}}, label: '-100% battery power' 
    Other 0x7fc2637a6a90: {{0.0, 0.0}, {375.0, 20.0}} 

这有可能是我提出的观点控制器,但我看不到任何东西的对象是由于他们都被“其他“

回答

0

请尝试按内容直接访问单元格。

XCUIApplication *app = [[XCUIApplication alloc] init]; 
[app.staticTexts[@"Cell One"] tap]; 
+0

已经尝试过,并没有帮助。查看元素检查器时,尽管它们在屏幕上,但2个按钮上的文本不会出现。我没有对视图控制器做任何特殊处理,它是一个非全屏模式,具有自定义过渡。 – yak

0

容器视图内的元素通常无法访问。使PopOverViewController不可访问,并且单元格应该可用。

self.isAccessibilityElement = false 

在视图控制器上执行此操作,然后像往常一样查询单元格。

app.cells.elementBoundByIndex(0).tap() 
+0

感谢您的回复。我试过这个以及无济于事。在显示弹出窗口之前和之后,我已经从元素树中获取了打印输出,并且它不会更改,新元素不会出现在元素树中。 – yak

+0

@IanYakHoughton你可以在弹出之前和之后添加输出到你的'app.descendantsMatchingType(.Any).debugDescription'的问题吗? – Oletha

+0

我已经将输出添加到我原来的问题中,并且文本被删除了。我可以看到'PopOverViewController',但没有任何关联。 – yak

0

我试图通过删除故事板上启用的辅助功能标志来解决此问题。在此之后,这些单元格在元素检查器中变为可见。

相关问题