iOS UI Testing : Failure getting list of active applications: AX error -25205

一曲冷凌霜 提交于 2019-12-07 11:33:38

问题


I am still learning how to use UI Testing properly.

I login in the background and later, I show result in my news feed. Then, I tap on more button. When there is web service, it look like I can't get result from my api. It always fail like this and data from my api are not shown also. How shall I do?


回答1:


I had same issue while using simulator. I tried running test case on device and it is working fine. So Run on actual device and see if error appears.




回答2:


You shouldn't be using sleep() in your tests. Instead, use the native APIs to wait for elements to exist. For example, you can wait until the "Contests" text appears with the following:

XCUIApplication *app = [[XCUIApplication alloc] init];
XCUIElement *moreButton = app.tabBars.buttons[@"More"];

XCUIElement *contestsText = app.staticTexts[@"Contests"];
NSPredicate *exists = [NSPredicate predicateWithFormat:@"exists == YES"];
[self expectationForPredicate:exists evaluatedWithObject:contestsText handler:nil];

[moreButton tap];

[self waitForExpectationsWithTimeout:5.0f handler:nil];
XCTAssert(contestsText.exists);

This example comes from my UI Testing Cheat Sheet. If you are just getting started with UI Testing I recommend you check it out.




回答3:


Resetting the simulator resolved the issue for me. It can be done by Simulator - Reset Content and Settings... from the main menu of the simulator.

To use with CI systems, these commands might help:

osascript -e 'tell application "iOS Simulator" to quit'
osascript -e 'tell application "Simulator" to quit'
xcrun simctl erase all


来源:https://stackoverflow.com/questions/36133484/ios-ui-testing-failure-getting-list-of-active-applications-ax-error-25205

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!