xcode-ui-testing

XCode7 UITests how to test screen edge pan gestures?

喜夏-厌秋 提交于 2019-12-10 11:24:46
问题 I have the following gesture recognizer in my app. I've looked at xCode7 UI and see that it has swipe up/down/left/right, but no pan or edge pan gestures. How can one test or initiate screen edge pan gesture for UITesting purposes? UIScreenEdgePanGestureRecognizer *leftEdgeGesture = [[UIScreenEdgePanGestureRecognizer alloc] initWithTarget:self action:@selector(show)]; leftEdgeGesture.edges = UIRectEdgeLeft; leftEdgeGesture.delegate = self; [self.view addGestureRecognizer:leftEdgeGesture]; 回答1

Any way to automate SFSafariViewController in UI tests?

南笙酒味 提交于 2019-12-10 02:11:47
问题 Is there any way to automate SFSafariViewController? I like the Xcode 7 UI test feature, but it seems it does not support SFSafariViewController automation. Some of the UI flows I am testing require a web browser so the app uses SFSafariViewController to make it safer vs a web view. 回答1: If it's similar to launching extensions (currently broken with direct interactions), try tapping the screen at the point where the element you're looking for is: Example of tapping an action sheet which

Xcode UI testing - Uiviews added with addSubview are completely invisible to the UI tests

左心房为你撑大大i 提交于 2019-12-09 07:16:23
问题 I've been giving a try to the new UI tests on XCode 7.3 and I've found what it seems a bug to me. The problem is that views added through the " addSubview " method seems to be completely invisibles to the UI test system. I have this view: And this UIview creating code: let container = UIView(frame: CGRectMake(0, 0, 375, 200)) container.backgroundColor = UIColor.orangeColor() container.isAccessibilityElement = false let label = UILabel(frame: CGRectMake(0, 100, 375, 20)) label.backgroundColor

UITest color of a label (not UI label)

好久不见. 提交于 2019-12-08 15:44:49
问题 Here is a pic of the table I'm working with. I'm just trying to get the color of "requested" (gray) or "draft" (orange). I'm able to get the actual string of "requested" or "draft" by var timeSheetStatus = app.tables.element.cells.elementBoundByIndex(0).staticTexts.elementBoundByIndex(1).label but this is just a string and not a UIlabel (if it were a UILabel I would be able to do label.textColor I believe). How do I get the color of this string so I can assert that it is indeed gray or orange

UITesting Failure getting list of active application

泪湿孤枕 提交于 2019-12-08 04:41:20
问题 There is a button by clicking on the button it opens facebook login page and clicking on the done button it gets back to the main view controller. Here is the code which I got by recording override func setUp() { super.setUp() XCUIApplication().launch() } func testExample() { let app = XCUIApplication() app.buttons["Button"].tap() app.buttons["Done"].tap() } But when I run the recording it gives error in the second line of testExample() Here is the error: UI Testing Failure - Failure getting

How do I access my swift classes from my UI tests?

痞子三分冷 提交于 2019-12-08 04:32:51
问题 I have a UI test like so : func testHome(){ if(isRedOrange.clear()){ //code } } How would I access my isRedOrange.clear function from my isRedOrange.swift file from my UI tests? 回答1: UI Tests are black boxed, so you cant have access to your code . You can use @testable import in Unit Tests , so full access will be provided. When you're running UITests this is not working, because during a UITest your test class cannot access your app's code. From Apple's Docs: UI testing differs from unit

XCTestCase not launching application in setUp class method

不想你离开。 提交于 2019-12-08 01:36:22
问题 I am using XCode 8 and XCTestCase. I created a class setUp function to be ran once before all tests, and the other setUp to be ran before each test case. I want the application to be launched once before all test cases. If I use the launch in the class setUp, it never gets executed. If I use the launch in the setUp that is ran before each test, it does launch the test. It prints: IN CLASS SETUP END CLASS SETUP IN SETUP IN TEST METHOD But the application never gets launched. If I uncomment the

How to test UITextField in Xcode UI Testing when the text field is empty?

有些话、适合烂在心里 提交于 2019-12-07 13:42:01
问题 I am making a UITest in Xcode. When I record my test it works fine but when I run the test, it gives an error. These are the lines of code where the error occurs: XCUIElement *clearTextTextField = [app.textFields containingType:XCUIElementTypeButton identifier:@"Clear text"].element; [clearTextTextField typeText:@"sheffield"]; The error says UI Testing Failure - No matches found for textfield I imagine this is because my Text Field does not have any initial string and the tester cannot find a

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

How can I change the time required to get a snapshot in Xcode UI Test (XCUITest)?

拈花ヽ惹草 提交于 2019-12-07 07:51:26
问题 I'm doing some performance experiments and I keep getting this error with my Xcode UI Tests since no new UI Test statement is hit: UITesting Failure - Failed to get snapshot within 15.0s How can I change this 15.0s variable to something longer? Is there some configuration or setting that I can change? 回答1: You can use expectations to allocate an arbitrary amount of time to run any test case. You just create an additional expectation right before 15.0s has passed, and repeat this process as