I have a close button on a ViewController that is being presented as a ChildViewController. I have this button's accessibility turned on and the accessibility identifier is closeButton. This button does not have any text, it just has an image.
I am attempting to test the presentation and dismissal of this view, but am running into an issue, the XCUITest cannot find the element. My test code is:
app.buttons["PresentChild"].tap()
XCTAssertTrue(app.otherElements["ChildViewController"].exists)
XCTAssertTrue(app.buttons["closeButton"].exists)
The first assert passes, but the second assert fails.
I tried to do the "Record UI Test" to select the button to have it be automatically generated, but then I just get an error saying Failed to find Matching Element. I tried erasing all the content on the simulator and deleting all derived data, and that didn't work either.
Does anyone know a workaround to this obvious bug in Xcode? I can't access the element through the recording, I can't access the element through the accessibility feature, I have zero idea how else to access this button.
I don't know what is the exact problem with your assertion. But this steps may help you.
Put a breakpoint on this line XCTAssertTrue(app.otherElements["ChildViewController"].exists)
Now run the test case. When the control reaches this line, type this line in the debugger po XCUIApplication().buttons.debugDescription then tap the enter button
It will print all buttons in your current view. Now check whether the "closeButton" exists in that list
If it exists, check the identifier name. Make sure that it is "closeButton" (Identifier is case sensitive, also spaces in the identifiers matters)
If the identifier is right, try to find out the closeButton's exact view hierarchy. Means, instead of just checking like app.buttons["closeButton"].exists, try like app.navigationBars.otherElements["someName"].buttons["closeButton"].exists
(This seems funny, but giving the exact location path of the element is a good practice, and it will work sometimes)
Note: This error "Failed to find Matching Element" on UI recording will happen if the system can not locate the element with proper identifier while doing action on it. So my guess is, your closeButton does not have proper identifier or it is not added to the current window.
Cheers!!
Related
I'm using xcode 13 and making a demo on coredata.
objc[6188]: Class _PathPoint is implemented in both
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
(0x114a8fa78) and
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TextInputUI.framework/TextInputUI
(0x12cd4a8b0). One of the two will be used. Which one is undefined.
objc[6188]: Class _PointQueue is implemented in both
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore
(0x114a8fa50) and
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TextInputUI.framework/TextInputUI
(0x12cd4a8d8). One of the two will be used. Which one is undefined.
Apple developer Quinn “The Eskimo!” # Developer Technical Support # Apple answered this question here:
This is not an error per se. Rather, it’s the Objective-C runtime telling you that:
Two frameworks within your process implement the same class (well, in this case classes, namely _PathPoint and _PointQueue).
The runtime will use one of them, choosing it in an unspecified way.
This can be bad but in this case it’s not. Both of the implementations are coming from the system (well, the simulated system) and thus you’d expect them to be in sync and thus it doesn’t matter which one the runtime uses.
So, in this specific case, these log messages are just log noise.
This error usually happens when you add a gesture recognizer inside a view that also has a gesture recognizer of its own. In your case, you may have added the textField as a subview of a view that has some sort of gesture recognizer, or scroll. So when you tap on that textField, it does not know which gesture to trigger. So, look into your implemetation and figure out if the textView is inside another view that has a geture.
In my case, I created a view, which had a gesture recognizer, and this view had a UITextView() as a subview. So when the parent view was tapped and the gestured was used, I would get this error. I solved it by disabling user interaction on my textView.
textView.isUserInteractionEnabled = false
I got this error when using Rosetta to open Xcode 13.1.
After disabling the option "open with Rosetta" those errors were gone.
I was getting the same error. I had hyperlink in textView
--> ex "I’ve read the Privacy Notice ..."
Then I realized that the link I entered into the hyperlink must meet the universal conditions. My hyperlink is;
wrong case --> "https://www.AçıkRıza.com"
true case --> "https://www.acikriza.com"
I was then able to build it successfully.
I am following the Stanford University iOS development course on iTunes U.
In one of the demos (that I have been trying to follow), there is this code that loads the property list from an NSURL and returns it as NSMutableDictionary.
-(NSMutableDictionary *) words
{
NSURL *wordsURL=[NSURL URLWithString:#"http://cs193p.stanford.edu/vocabwords.txt"];
words=[[NSMutableDictionary dictionaryWithContentsOfURL:wordsURL] retain];
return words;
}
The application is successfully built, but at runtime it gives the following error and gets stuck:
I can't figure out what the problem is. Can you please help?
You're stopped at a breakpoint. That's a debugging tool, not an error. See the blue arrow/tab in the left margin, where the line numbers are? Drag that away and drop it anywhere (you'll see a "poof") to remove it, then run your project again.
You can also deactivate all breakpoints by typing ⌘-Y, the key equivalent for the menu item Debug>Deactivate Breakpoints, or you can view all your breakpoints in the Breakpoint Navigator (hit ⌘-6).
When execution stops like this, you can continue from the breakpoint, either by typing continue at the debugger prompt in the Console:
(lldb) continue
Or hitting the "Play" button in the debugger controls. You can also type Control-⌘-Y, which is the equivalent for the menu item Debug>Continue.
This isn't an error. You just set a breakpoint (probably without knowing it).
Drag the little blue Chevron in the column at the left out of the way. You will see it disappear and go poof, and then you can rebuild your app and you should see it run properly.
Now, that said, I think there are some memory management mistakes in your code, but we can return to those later. ;-)
The program is stopping because you have a breakpoint.. That's the blue arrow on the left of the code. Right-click it and delete.
I have UITableViewCell which has Subject,Name,Description,time. When I am testing this on Appium the xpath changed for UIElement for Subject line only.
xpath:-subject line: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[3]**/UIAStaticText[2]**
after changes
xpath:-subject line: //UIAApplication[1]/UIAWindow[1]/UIATableView[1]/UIATableCell[3]**/UIAStaticText[3]**
Which is giving another UI element details, which fails the testing. How to handle this from Appium, or do I need to fix it from Xcode?
Basing on xpaths is not a really good idea.
But sometimes it is the only way to develop your scripts if there are no static ids nor accessibility labels available.
Your element that was previously set as: UIAStaticText[2], so as I suppose it was second element available at current screen. Now looks like UIAStaticText[3] - it is marked as third. If you are not able to see changes on the screen that you are automating, that can be caused because of an element that is under in the background it can be hidden.
The best approach will be with using static resource id's in your scripts or accessibility labels which you have mentioned in comment you've them already set and available.
Background:
I'm experimenting with ui level testing in iOS 9.0 with XCode GM.
Question:
Is there a command in XCode GM that will allow you to see a 'tree' of accessible elements and their relationships? Something similar to the 'page' command in Appium?
Ideally I would be able to run a command in the debugger that would give me a list of elements available for selection/manipulation. Currently you can use debugDescription on a single XCUIElement but that only gives you info for that element.
Set a break point where you would like to see the tree... in the debugger type:
po print(XCUIApplication().debugDescription)
That prints out everything XCUITesting has access to. You can also just throw that in to your test:
func testTreeExample() {
XCUIApplication().buttons["login"].tap()
print(XCUIApplication().debugDescription)
XCUIApplication().buttons["next"].tap()
print(XCUIApplication().debugDescription)
}
Thta way if you are having trouble finding something you can have it automatically print out what the app sees right after you do something.
This isn't exactly what you're asking for, but Xcode’s Accessibility Inspector makes it much easier to look at your view hierarchy in terms of what elements are accessible via Identifiers. (N.B. It's not the "Label" in IB's Accessibility panel that matters, it's the "Identifier" field.):
In Xcode 7.2, open Xcode->Open Developer Tool->Accessibility Inspector. (You may need to give the app permission to run in System Preferences.) Then launch your iOS app from Xcode and hover over any UI element in the SIMULATOR. You’ll see comprehensive information about the element type, description, hierarchy, etc.
Anytime you record UI actions and the output doesn't look right, use the tool to figure out what accessibility descriptions need to be added, changed, or removed. (I spent a couple days trying to get a deeply embedded UISegmentedControl to change via the UI Test harness, and the problem became obvious once I figured out how to use the Accessibility Inspector tool.)
Thanks to the folks at shinobicontrols.com for the great tip!
I would suggest choosing from the menu bar: Debug > View Debugging > Capture View Hierarchy when running in debug. Not only do you a way of visually representing the views but also the left-side debug navigator shows the hierarchy. This may not be one-for-one with UI Testing's perspective but it can be very helpful. Hope that helps.
The way Appium does this is using Facebook WebdriverAgent.
As far as I can tell, the way they do it, essentially, is starting from the root application element and collecting information about each child, then recursing.
What about http://fbidb.io?
With idb ui describe-all command you get the accessibility information of all the elements on screen (not the entire app) https://fbidb.io/docs/commands#accessibility-info
Put a breakpoint in any of your tests then just do: po XCUIApplication() and that will print out the whole app's accessibility hierarchy in easy to read tree format.
Is there a way of having Xcode tell me what function is not implemented correctly that is triggering its "incomplete implementation" warning?
Sometimes method names are not shown in the in-code warnings. In that case:
Go to the Issue navigator (the warning sign in the left pane), expand the warning, click on "Method declared here".
First, click the little arrow (1), then click one of the method names (2).
If you click on the warning sign that Xcode displays at the very end of the file which is missing a method definition, you will see an additional message telling you which method it is.
yes when you got this warning click on it .. for example it will take you the .m file .. in the warning there is a number for the methods in not implemented .. click on it and you will got the methods .. check the snap shots below.