Issue facing for xcode-ui-testing in XCode 9 - ios

UI Test for an ios-app, developed in XCode 8 and swift 3.2.
Facing problem to deal with ScrollViews, collectionViews after upgrade XCode to 9
I can tap and access the Buttons, StaticTexts, TextFields elements.
But I can not tap or access the collectionviews, scrollviews, tableviews elements on XCode9 and Swift 3.2.
Suppose in the previous XCode version (i.e, XCode 8.3) I used the code app.collectionViews.collectionViews.cells.images.element(boundBy: 0).tap()
to tap on Home page(collectionViews). But this code is not working in XCode 9.
I tried to get the exact element using uitest recording feature.
By using recording I got the code -
app.collectionViews.otherElements.containing(.textField, identifier:"StoryboardTitleTextField").children(matching: .collectionView).element.tap().
But this code isn't working too. So how can I resolve this?
Thanks

Recently i also faced the similar type of issue after upgrading my project(Swift 3.2) into XCode 9.
The issue is
app.collectionViews.collectionViews.cells.images.element(boundBy: 0).isHittable is returning false.
Thats why default tap() method is not working for hierarchical elements.
I just did the below procedure and that worked fine.
Step 1: Create an extension like below
extension XCUIElement {
func tryClick() {
if self.isHittable {
self.tap()
}
else {
let coordinate: XCUICoordinate = self.coordinate(withNormalizedOffset: CGVector(dx:0.5, dy:0.5))
coordinate.doubleTap()
//coordinate.press(forDuration: 0.5)
}
}
}
Step 2: click on the element using the instance method created above instead of using direct tap() method.
app.collectionViews.collectionViews.cells.images.element(boundBy: 0).tryClick()
Note: try using
CGVector(dx:0.5, dy:0.5) or CGVector(dx:0.0, dy:0.0)
Hope it will solve your issue. It worked like a charm for me.

Related

SDWebImage not setting images in UITableView cells until scroll in Xcode 9.0 beta

I have been using SDWebImage in one of my projects for quite long and accidentally happened to open the project up in the recently released Xcode 9.0 beta. The library was working absolutely fine on the previous versions so I can't help but think it's Xcode that's broken it.
The issue I am facing is that the images in UITableView do not get set when the cells are initially loaded. The images are set only when scrolled out of the view and then back in. I have tried setting placeholder images but to no use. Any help would be very much appreciated. I have been banging my head over this for quite a while now and can't find any solutions.
Use this is in your code when all the data in tableView is loaded successfully
dispatch_async(dispatch_get_main_queue(), ^{
[self.tableView reloadData];
});
So the answer to this, for now, is -
I was giving my UIImageViews a value relative to its height in the following manner -
cell.userImage.layer.cornerRadius = cell.userImage.frame.size.height / 2;
Changed it to -
cell.userImage.layer.cornerRadius = 25.0f;
And it's working just fine. Not sure where the issue is but I am assuming that it's got something to with the storyboard/constraints in the Xcode 9.0 beta.

SWRevealViewController and pauseInteractiveTransition not implemented

I use SWRevealViewController in a lot of my projects. Since updating to Swift 3 with an iOS deployment target of 10.0 or higher, I am now getting a warning Method 'pauseInteractiveTransition' in protocol 'UIViewControllerContextTransitioning' not implemented in SWRevealViewController.m
I see that this is a required for UIViewControllerContextTransitioning but I have no idea how to implement it. So I just added this
- (void)pauseInteractiveTransition {
// not implemented
}
Everything is working fine but I want to know if there is something else I should do.

can multiple buttons be attached to a single IBAction is Xcode 8?

I have tried to connect several buttons to a single IBAction in Xcode 8 however it does not work. I tried the practices outlined here Xcode8 cannot connect multiple/single uibuttons to single #IBAction in swift file still to no avail. can anyone shed some light as to why or if it is simply still just a bug?
Works fine for me in Xcode 8.1 on a new Swift 3 project. You have to control-drag from the button to the center side of the method to select it if it already exists rather than drag to the left side.
change your parameter from (_ sender: Any) to (_ sender: UIButton), and you're good to go.
There is no reason why several buttons should not connect to a single action function in your code. I had no trouble doing this when I tried it, as you can see:
However, if the nib editor interface won't let you form the connection, configure the action-target of the buttons in code.
Double check if you want to add action to a real button
Check if when you wrote the action, you used some customized class instead of UIButton, and the class of your button does not match.
I was able to resolve the issue by upgrading to Xcode 8.1 and including an _ before the sender argument. I believe this is just a bug from Xcode 8 because I tried the latter before upgrading and I was still unable to connect.

swift 3.0 folding-cell library table not showing

I am using https://github.com/Ramotion/folding-cell library into my Swift 3.0 projects. It works nice without any editing or changing on storyboard/auto layout changing.
I faced some issues when tried to:
Add few IBOUTLET (in DemoCell.swift)
Add Data to them (in DemoCell's didSet() method)
Now the view is blank. But i can scroll the tableview(it is just not showing), can click and can see folded cell perfectly.
I tried to add constrains as it given in documentation. I get fatal crash.
I am using Xcode 8, swift 3.0. This is happen always even when i download the fresh source code and add new uilabel or anything change on storyboard.
Does anybody tried this library recently ?
Blank Screenshot:
When click in the cell, Other cell is hidden.But clickable.
Foreground view:
It was an issue with the library. Now its solved.
Thread: https://github.com/Ramotion/folding-cell/issues/69#event-819438913

IBAction in Xcode 4.5

Anybody experiencing no response for IBAction touchUpInside in Xcode 4.5, deployment target iOS 5 as well? It works in simulator for me having iOS6, but not iOS5.
I had this same issue because I was using a tap gesture. You should be able to keep your existing code by adding the line below. This will keep your tap gesture from killing any taps on interior buttons and such...
yourTapGesture.cancelsTouchesInView = NO;
Edit:
I have found the solution. I was adding a tap gesture to the view, which was overriding the view's ability to detect a touchUpInside action on any buttons since they are part of the view as well. So what you should do is either remove the gesture recognizer or make it specific to a certain object. For example, I added the touch gesture to the specified part of the view that was not on the subview (I created a new object / outlet and labeled it as such). Still not sure why it's different in 5.1 vs. 6.0, but this should help you.
Original Post:
I am having the same issue. I have a project where buttons on a subview are clickable on version 6.0 of the simulator but not version 5.1. I have some gesture recognizers in there as well but commented them out to see if they were the issue and they are not. The only thing I have found is that the buttons are sometimes clickable on a touch up outside action (even though they are programmed for touch up inside), so I am not sure if maybe Apple changed the eNums for button actions? If I come up with a solution I will be sure to provide it here.
I just created a new demo project. I added a button to a view, handle touchUpInside, built and tested using Xcode4.5 on both deployment target ios6 and ios5 - both worked just fine. Try with a demo project yourself - won't take more than a few min.

Resources