xcode-ui-testing

UI test fails when it types text into a text view when run by an Xcode bot

南笙酒味 提交于 2019-12-03 11:24:21
问题 I have the following XCTest UI test that types text into a text view. let textView = app.textViews.elementBoundByIndex(0) textView.tap() textView.typeText("Hello world") When run as an Xcode bot it shows the following error for the typeText call. Assertion: UI Testing Failure - failed: Timed out waiting for key event to complete Interestingly, when I run it manually from the Xcode on the same computer the test passes. This test also passed in Xcode bot before upgrade to Xcode 7.1 / iOS 9.1.

How do I perform a tap and drag in Xcode UI Test scripts?

独自空忆成欢 提交于 2019-12-03 10:16:47
问题 For example, I have a sketch pad app that I want to test by drawing on it. I'd like to specify an (x,y) coordinate and make it tap and drag to another (x,y) coordinate. Is this possible in Xcode UI Tests? Joe provided a solution to this issue: Using objective C, my code looked something like this: XCUICoordinate *start = [element2 coordinateWithNormalizedOffset:CGVectorMake(0, 0)]; XCUICoordinate *finish = [element2 coordinateWithNormalizedOffset:CGVectorMake(0.5, 0.5)]; [start

Is it possible to stub HTTP requests in Xcode 7 automated UI tests?

随声附和 提交于 2019-12-03 08:06:15
I've been trying to intercept and stub/mock HTTP requests in Xcode 7 automated UI tests, using tools like OHHTTPStubs , with no luck. Here's an example of how I am trying to capture any HTTP request using OHHTTPStubs in the setUp method of a UI test file: override func setUp() { super.setUp() let matcher: OHHTTPStubsTestBlock = { (request) -> Bool in return true } OHHTTPStubs.stubRequestsPassingTest(matcher) { (response) -> OHHTTPStubsResponse! in return OHHTTPStubsResponse.init() } } Is there something about the way that UI testing works that prevents this? has anyone been able to achieve

How to obtain reference to TextField in UI Tests in Xcode 7

孤街醉人 提交于 2019-12-03 06:13:19
I am trying to use UI tests in xcode 7 beta. I have a storyboard with two text fields. Both text fields have outlets and different Restoration IDs. I recorded the test but generated code is quite unreadable and it doesn't work: app.otherElements.containingType(.TextField, identifier:"y").childrenMatchingType(.TextField).elementBoundByIndex(0).typeText("hello") I also tried the following and will work based on Placeholder text?!? app.textFields["PlaceholderText"].typeText("hello") What is the right way to obtain a reference to a TextField in UI tests? You need to set accessibility identifier in

How to open url in Safari and the get back to the app under UITests in Xcode 7?

荒凉一梦 提交于 2019-12-03 05:47:30
This is my custom view where "LondonStreet" is a button. When I tap that button I get url and open it in Safari (it works). Then I can go back, using "Back to Wishlist" button (it also works). The problem is when I try to test this under UITests. itemsTable.cells.elementBoundByIndex(0).buttons["addressButton"].tap() //press the button to open link in Safari Along with this line: app.statusBars.buttons["Back to Wishlist"].tap() //go back, doesn't work, although it was recorded by Xcode itself. is an error: UI Testing Failure - Failed to get screenshot within 5s. And also in issue Navigator UI

Replicate pull to refresh in XCTest UI testing

戏子无情 提交于 2019-12-03 05:29:12
I am trying to replicate a pull to refresh on a UITableView using the new Xcode UI testing framework in Xcode 7 (beta 3) My current approach is dragging from the table to whatever element below the table I can find. This works when there is a fixed item below the table like a UIToolbar or UITabBar I would rather not rely on having a UITabBar or UIToolbar but I can't figure out a way to do the pull to refresh/drag action without using the method in XCUIElement . func pressForDuration(duration: NSTimeInterval, thenDragToElement otherElement: XCUIElement) But it fails when I don't have a toolbar

Xcode 7 UI Tests, Recording button is greyed out

我的梦境 提交于 2019-12-03 04:22:07
I am trying to add UI tests to my existing project using Xcode 7. However the UI test recording button is always greyed out. What I am missing here? I tried restarting Xcode, cleaning and rebuilding the project and adding a new UI test target. Does anyone else experience the same behaviour? FWIW: I had this problem and it turns out I was trying to run the simulator in the wrong OS. I was trying to use iOS8.x, and UITesting only works in iOS9+. Switch the simulator version, and the record button appears. To enable the red button, you have to have the cursor on the test method: I got stuck on

‘NSInternalInconsistencyException’ when running UITesting with Xcode 7

梦想与她 提交于 2019-12-03 04:15:21
Ok, I’ve not been able to run this test in any betas so far. Some of the issues I’ve encountered are here and here Now, I feel like I’m missing something. Here’s my progress so far Enabled “UI testing” option while creating a new project. This, in fact adds a target for me. So I should be good to go - or so I thought. The swift file under UI Testing had already “XCTest” imported and was a subclass of “XCTestCase”. setup() launches the application XCUIApplication().launch() And I added the following (by hitting the Record button) And then, I ran this test. The whole thing fails even before the

How to write UI tests covering login with Facebook in Xcode?

不问归期 提交于 2019-12-03 03:42:44
I would like to write a UI test in Xcode covering a login with FBDSKLoginKit . However, Facebook iOS SDK uses SFSafariViewController presented to the user in order to authenticate her and unfortunately, there's no way how to interact with SFSafariViewController in UI tests in Xcode 7 . Any ideas how to test the facebook login without interacting with SFSafariViewController ? thexande Swift 3 Xcode 8 solution func testFacebookLogin() { let app = XCUIApplication() // set up an expectation predicate to test whether elements exist let exists = NSPredicate(format: "exists == true") // as soon as

Scroll until element is visible iOS UI Automation with xcode7

那年仲夏 提交于 2019-12-03 01:58:40
问题 So with the new xcode update apple has revamped the way we do UI testing. In instruments we used java script function "isVisible" to determine if our targeted element is visible. I'm trying to replicate this in objective c but i can't seem to find the equivalent of this. I have a table view, a prototype cell with two labels on it. This prototype cell is reused 50 times lets say. I'm trying to scroll until the last cell is visible, i did this by doing this: if (![[[[[[XCUIApplication alloc]