Reputation: 6143
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?
Upvotes: 4
Views: 797
Reputation: 479
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
Upvotes: 0
Reputation: 1016
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.
Upvotes: 2
Reputation: 17018
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.
Upvotes: 1