Xcode UI Tests can't find views that are added programmatically
You need to make sure that the container view of your label view (UIEditText?) doesn't have isAccessibilityElement
set to YES. If it does it will hide the accessibility of its subviews (your label).
Check Make the Contents of Custom Container Views Accessible in the Accessibility Programming Guide
Can not access the programatically added UIView in XCTest
The line in question is very brittle. It's possible that your app's views are not always available in the same order every time the app launches, depending on race conditions, so what was recorded in your recording session does not necessarily work for all launches of the app. You'll probably find that the code is actually running, but isn't tapping the element you expected.
To make your code less brittle, add an accessibility identifier to the UIView in your app code, and use the otherElements
query to find the UIView.
// app code
let view: UIView!
view.accessibilityIdentifier = "myAccessibilityIdentifier"
// UI test code
app.otherElements["myAccessibilityIdentifier"].tap()
UI Testing Failure - Neither element nor any descendant has keyboard focus on secureTextField
This issue caused me a world of pain, but I've managed to figure out a proper solution. In the Simulator, make sure I/O -> Keyboard -> Connect hardware keyboard
is off.
Programmatically creating Views in IOS (how does it work)?
To be even more specific to your question, the syntax would be
UIWindow* window = [UIApplication sharedApplication].keyWindow;
UIView *polygonView = [[UIView alloc] initWithFrame: CGRectMake ( 0, 0, 200, 150)];
//add code to customize, e.g. polygonView.backgroundColor = [UIColor blackColor];
[window addSubview:polygonView];
[polygonView release];
This is a pattern you will use for not only this but subviews afterwards. Also, another note is with many of the templates, the viewController is already set up with it's own view. When you want to make a custom view, you create it like above but instead of the method above you set the viewControllers view to the newly created view like so:
viewController.view = polygonView;
Good luck!
Related Topics
Wrong Text Height When Text Contains Emoji
Xcode 4.2 with Arc: Will My Code Run Even on iOS Devices with Firmware Older Than 5.0
Upgrading to Swfit 3: Cannot Override 'Init' Which Has Been Marked Unavailable
How to Schedule Mail Using Gmail API
How to Add Action to Uialertview in Swift (iOS 7)
How to Record and Save at 240 Frames Per Second
Whats the Correct Way, Using "Init" or "Didmove"
Fix Cursor Size for Modified Paragraph Spacing in Uitextview
How Come My Drawing Code Keeps Resulting in Fuzzy Shapes
How to Pair And/Or Bond to Ble on iOS Using Swift Code and an Hm-10 So Data Sent Is Encrypted
How to Convert Cgpoint in Nsvalue in Swift
Swift Uiview Opacity Programmatically
Core Data - Fetch All Entities Using the Same Field
How to Fix Broken Transform-Origin on iOS11 and Macos10.12 Safari
iOS Wkwebview Swift JavaScript Enable