1

I have recently started automating iOS apps on iPhone real devices with the XCUI test setup.

I got a scenario where my app contains 5 screens in the home page, each screen contains a unique card number and its balance so i have to fetch the card number from the screen and verify it with my input(expected) card number, if both are same then i have to click on the card screen otherwise if both are not same then i have to swipe right to the second screen and do the same process.

I was able to automate this scenrio in android perfectly because in android each screen is clearly differentiated with a unique card number but when i inspect the card number screen on iOS app it was showing all the list of cards attached to the app. in this case its getting difficult for me to get the card number from the app and verify it with my input card number . please see the below code which am already using it for android

String oysterCardVisibleNumberOnApp= data.get("PrestigeCardNumber");


while(!action.getText(HomePage.oysterCardNumber,"oysterCardNumber").equalsIgnorecase(oysterCardVisibleNumberOnApp))){
      action.swipeRightToLeft();
     }

it would be great if any one has any idea how to retrieve the list of elements/cards from the iOS app please let me know. or if you know any new methods in XCUI setup will help me to achieve this then please let me know. your help will be much appreciated :)

Please see the below Android Screen & iOS Screen pictures for getting more clarity

Android Screen

iOS Screen

Thank you

4

3 回答 3

3

例如,如果您在断点处停止并使用:

po XCUIApplication().descendants(matching: .any)

在调试控制台中,您将获得来自主应用程序元素的所有后代元素的列表。它还将使您对结构有一个松散的看法。

然后,您可以更改.any为更具体的元素类型,例如.textField.buttons

于 2018-04-04T13:28:42.027 回答
0

您可以使用XCUIApplication().debugDescriptionXCUITest 看到的 UI 树进行打印。您还可以更新应用程序代码来为您的 UI 元素设置自定义标识符(这些只有 XCUITest 可以看到)。例如card-1,等等。

于 2018-06-11T05:18:54.647 回答
0

您可能可以为此使用 xcode 中的 Accessibility Inspector:

https://developer.apple.com/library/content/documentation/Accessibility/Conceptual/AccessibilityMacOSX/OSXAXTestingApps.html

根据您在应用程序中选择的区域,它会返回每个区域的详细描述。但它带来什么取决于您的应用程序的结构。我试图在我自己的 ios 应用程序中做类似的事情,这对我有点帮助。

于 2017-12-08T12:24:08.113 回答