Sometimes when running UI tests, the tests fail on keyboard input because the "Speed up your typing" keyboard tutorial overlay obscures the keys. This happens randomly, but sometimes repeatedly.
Is there a way to turn this off? Checking for this tutorial before any keyboard input would significantly complicate tests just to check for one edge case...
Testing
RSS for tagDetect issues like logic failures, UI problems, and performance regressions by running tests on your app.
Posts under Testing tag
110 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
We are building an iOS app that connects to a device using Bluetooth. To test unhappy flow scenarios for this app, we'd like to power cycle the device we are connecting to by using an IoT power switch that connects to the local network using WiFi (a Shelly Plug-S).
In my test code on iOS13, I was able to do a local HTTP call to the IP address of the power switch and trigger a power cycle using its REST interface. In iOS 14 this is no longer possible, probably due to new restrictions regarding local network usage without permissions (see: https://developer.apple.com/videos/play/wwdc2020/10110 ).
When running the test and trying a local network call to the power switch in iOS14, I get the following error:
Task <D206B326-1820-43CA-A54C-5B470B4F1A79>.<2> finished with error [-1009] Error Domain=NSURLErrorDomain Code=-1009 "The internet connection appears to be offline." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x2833f34b0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorCodeKey=50, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <D206B326-1820-43CA-A54C-5B470B4F1A79>.<2>, _NSURLErrorRelatedURLSessionTaskErrorKey=("LocalDataTask <D206B326-1820-43CA-A54C-5B470B4F1A79>.<2>"), NSLocalizedDescription=The internet connection appears to be offline., NSErrorFailingURLStringKey=http://192.168.22.57/relay/0?turn=on, NSErrorFailingURLKey=http://192.168.22.57/relay/0?turn=on, _kCFStreamErrorDomainKey=1}
An external network call (to google.com) works just fine in the test.
I have tried fixing this by adding the following entries to the Info.plist of my UI test target:
<key>NSLocalNetworkUsageDescription</key>
<string>Local network access is needed for tests</string>
<key>NSBonjourServices</key>
<array>
<string>_http._tcp</string>
</array>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
However, this has no effect.
I have also tried adding these entries to the Info.plist of my app target to see if that makes a difference, but it doesn't. I'd also rather not add these entries to my app's Info.plist, because the app does not need local network access. Only the test does.
Does anyone know how to enable local network access during an iOS UI test in iOS14?
I have recently started Beta Testing my SwiftUI App on my iPhone 6s, previously I was testing it on the iPhone 12 Simulator. While Testing on the Real Device I encountered issues like: CPU going past 98%
Really Laggy ScrollView
Tab Bar Freezes Randomly
Since My app is going to go in Production State in a few days, Since this is my first iOS App as well, I am not too sure if these issues are because of SwiftUI, my Phone or what, I have asked Apple Support but, haven't received a response so far.
My App Stats:
Lines of Code: ~1,500
CPU Usage on Simulator: Max. 10%
Bundle Size: 2MB
RAM Max. on Simulator: 32.3mb
Test UI and unit tests are working fine on 14.3 with XCode 13.0 beta4 but it gets stuck on 15.0 and doesn't execute any test case with no error.
We got the newly issue that our Test devices keeps us asking for the pin code to "Enable UI Automation".
Then it works for some hours or days, but after some time it starts again.
"Enable UI Automation" is already enabled in "Settings" - "Developer" menu.
The devices are located remotely and we can't access them directly, so this is a big issue for us right now.
Is there any way to avoid this?
We are having an issue when trying to view the the coveage report in our "merged result bundle"
Running xccov view --report --only-targets merged.xcresult results in:
09:52:54 Error: Error Domain=XCCovErrorDomain Code=0 "Failed to load coverage archive in scheme action '(null)' in result bundle" UserInfo={NSLocalizedDescription=Failed to load coverage archive in scheme action '(null)' in result bundle, NSUnderlyingError=0x7f8ff8714f30 {Error Domain=NSCocoaErrorDomain Code=260 "The file “Metadata.plist” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/tmp/action.xccovarchive/Metadata.plist, NSUnderlyingError=0x7f8ff8714930 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}
Checking the man page for xccov I was inspired by the idea of extracting the coverage report from the result bundle to try to understand or work around our error.
The man xccov page states that
If xccov is passed a result bundle directly, it will extract the report or archive implicitly, as part of the action being requested. Alternatively, the raw report/archive files can be extracted from the result bundle using xcresulttool(1) and subsequently passed to xccov.
Checking man xcresulttool and trying out some stuff randomly I was not able to learn how a person might:
Given an xcresult bundle use xcresulttool to create/extract an xccovreport bundle.
I try adding people as Sandbox Testers to my App, but Apple keeps saying that they already exist on the team, even though they're not.
It always show "A user with this email address already exists on the team"
It keeps happening with every address I try.
On an intel mac, my XCUITest test cases which is included swipe actions works perfectly but it doesn't work on my m1 mac. I tried running simulator with Rosetta but it doesnt work out it still gives an error when I run my cases because it clicks instead of swipe.
Does anyone have a solution for swiping problem on the m1?
Hi,
I'm currently researching if we are able to migrate to Xcode Cloud in our project. I encountered one issue.
I run unit tests on Xcode Cloud and I see that they finish in ~150 seconds, but the whole step takes ~530s and there is no information in logs why. I even run the same command on my local computer and it doesn't take that long. Any ideas? Any way to optimize it?
Also one more thing: it looks like Xcode Cloud is not running on M1 machines. Do you know guys if there are plans for Xcode Cloud to take advantage of M1/M2?
I've been reading through the documents and I feel like each particular doc jumps over the piece of info that I need. It explains how to create a Sandbox Test User and I've done that. I did plenty of IAP work many years ago, but things have changed enough that it's not working as I expect. When I read the docs, I feel like I can't find the missing piece.
When I test in a simulator with Xcode, it does my IAP transactions in the Xcode environment. That makes sense.
https://developer.apple.com/documentation/storekit/in-app_purchase/testing_in-app_purchases_with_sandbox
This page says:
To run your app using your Sandbox Apple ID, build and run your app from Xcode.
But when I test on a physical device installing directly from Xcode, it also does my IAP transactions in the Xcode environment. I thought this would put me in the Sandbox environment, but it didn't. The initial purchase view controller didn't reference the Sandbox at all and the "You're All Set" alert shows Environment: Xcode.
When I put a test build into TestFlight and test using that version, my IAP transactions are happening in production using my real Apple Id (but I'm not actually charged for any transactions).
I assumed that testing in TestFlight would give me the Sandbox environment, but it happens in the Production environment. (The purchase view controller doesn't show Sandbox and the "You're All Set" alert doesn't show Sandbox.)
So, how do I test in the Sandbox? Every way I try to test either puts me in the Xcode environment or the Production Environment.
What am I missing?
I've logged out of my real Apple id on my phone and then logged in with the Sandbox User credentials I created in AppStore Connect. But when I tried to test the app, by installing from Xcode it still says I'm in the Xcode test environment. When I create transactions, those transactions show up in the Xcode Transaction Manager.
How do I test in the Sandbox environment?
Hello,
I'm trying to upload my code coverage to an external service.
I've created a workflow on Xcode Cloud that build and run my test + a ci_post_xcodebuild script that uploads my Project.xcresult to an external service
My problem here is that I need the repository source code the moment I upload my coverage file.
I have two steps in my workflow:
Build tests (Which contain the sources but not the coverage results)
Run tests (Which contain the coverage result but not the sources)
I found this in the Apple documentation:
Lastly, it should be noted that in a test action, multiple environments are used to build and run your tests. Only the environment that is used for building your tests will have your source code cloned into it by default. The environments that run your tests won't have source code cloned into them. They'll only have the ci_scripts folder made available on them. As a result, the post-clone script won't run in these environments and your custom scripts and any of their dependencies, such as other shell scripts and small tools, must be entirely contained within the ci_scripts folder.
Source: https://developer.apple.com/videos/play/wwdc2021/10269/
I feel a bit stuck here maybe Xcode cloud is not the way to go for this but I was wondering if by any way I could still check out my project sources after the test execution.
I have a simulator named "iPhone 14 Pro" created and booted. The override --time command doesn't appear to take anymore. This worked months ago, but broke somewhere along the road of Xcode 14.x. It is a drag setting the system time to 9:41 for App Store Connect screenshots which is why I used the command in the first place.
I cannot seem to successfully set the status bar time of the simulator via the following command anymore: xcrun simctl status_bar "iPhone 14 Pro" override --time "9:41"
Is this working for anyone else lately?
Feedbacks; Created these Dec 7, 2022
FB11859751 - Simulator: iOS simulator not responding to simctl set time
FB11859744 - Simulator: watchOS simulator not responding to simctl set time
Hi friends,
I have a problem suddenly by archiving my app in XCode 14.3 I'm getting this errors:
Showing All Errors Only
Prepare build
note: Building targets in dependency order
error: Multiple commands produce '/Users/razvanu/Library/Developer/Xcode/DerivedData/Runner-aeiwqtydtcicmbcjpyzoxtfwhzig/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
note: Target 'GoogleUtilities-00567490' (project 'Pods') has create directory command with output '/Users/razvanu/Library/Developer/Xcode/DerivedData/Runner-aeiwqtydtcicmbcjpyzoxtfwhzig/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
note: Target 'GoogleUtilities-54e75ca4' (project 'Pods') has create directory command with output '/Users/razvanu/Library/Developer/Xcode/DerivedData/Runner-aeiwqtydtcicmbcjpyzoxtfwhzig/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
Multiple commands produce '/Users/razvanu/Library/Developer/Xcode/DerivedData/Runner-aeiwqtydtcicmbcjpyzoxtfwhzig/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/UninstalledProducts/iphoneos/GoogleUtilities.framework'
I tried all the solutions that I found, nothing works for me :( please guide me how to fix this issue, thanks in advance!
This is for MacOS
My app posts errors during its operation. Two years ago the following
used to be able to test whether the alert was correct (or
missing)
func isRightAlert(alertImgStr: String, target: String) -> Bool{
let app = XCUIApplication()
let ackdialog = app.dialogs["alert"]
let imageexists = ackdialog.images[alertImgStr/*"CaptureEclipse alert"*/].exists
//let full = app.debugDescription
XCTAssert(imageexists)
let acklist = ackdialog.children(matching: .staticText)
//NSLog( String(acklist.count))
var found = false
NSLog("Alert>>>>>>>>>>>")
for index in 0...acklist.count - 1{
<see if is is one of the expected ones>
}
<other tests>
}
Now that I am on Ventura with XCode 14.3 it is no longer able to detect
the alert. ackdialog returns as not found. imageexists is false which triggers the Assert
The alert is on the screen when the timeouts I added trigger
app.debugDescription justs lists all of my menu entries
These are my own alerts (NSAlert) and not system alerts.
The new test report, with the automatic video recording and scrubber, is great. I'm setting up different configurations for different languages to improve localization testing, but I was wondering if it was possible to make the simulator device type part of the configuration.
For example, I'd like to have a single test plan with an "iPhone 14" test plan, an "iPad Air" test plan, etc. Then I would just press Cmd-U, and Xcode would run through each device in sequence, leaving me with videos of each test run that I could review in the test report.
Is that possible?
Example Image:
Expected Behavior:
When an XCUIElement is rendered from a screen with (Initial Conditions):
An ImageView with..
isUserInteractionEnabled = YES…
IsAccessibilityElement = YES…
A nested button…
isUserInteractionEnabled = YES…
IsAccessibilityElement = YES…
Assigned to the ImageViews accessibility elements array
XCUIElement’s print statement includes the nested button
Current Behavior:
When an XCUIElement is rendered from a screen with:
(above Initial Conditions)
XCUIElement’s print statement only include the ImageView
Attempted Fixes:
Combinations of the Initial Conditions:
Attempted all combinations of Initial Condition variable values. (ie:
myImageView.accessibilityElements = [imageView, nestedButton]
myImageView.accessibilityElements = [nestedButton]
isUserInteractionEnabled = YES/NO [for both]
IsAccessibilityElement = YES/NO [for both]
etc…)
Debug Print:
Image View with No Descendants - Image, 0x7fa875d23e80, {{172.7, 292.7}, {45.0, 41.7}}, label: 'demo image'
po element.images and po element.buttons -
Find: Descendants matching type Image
Output: {
Image, 0x7fa876e14e70, {{-8.0, 99.0}, {136.7, 109.3}}
Image, 0x7fa876e14f80, {{-8.0, 741.7}, {136.7, 102.3}}
Image, 0x7fa876e13da0, {{269.7, 737.0}, {136.3, 123.0}}
Image, 0x7fa876e1a060, {{172.7, 292.7}, {45.0, 41.7}}, label: 'demo image'
}
Output: {
Button, 0x7fa875c12740, {{0.0, 47.0}, {68.0, 44.0}}, label: 'myApp UIKit'
Button, 0x7fa875c24f00, {{338.0, 47.0}, {44.0, 44.0}}, identifier: 'Settings Button', label: 'Settings'
Button, 0x7fa875c2c800, {{175.0, 533.0}, {40.0, 40.0}}
Button, 0x7fa875c2cf30, {{183.0, 541.0}, {24.0, 24.0}}
Button, 0x7fa875c2fa20, {{40.0, 659.3}, {153.0, 44.0}}, label: 'Left'
Button, 0x7fa875c30cd0, {{197.0, 659.3}, {153.0, 44.0}}, label: 'Right'
}
Comparing the coordinates of the parent image view and the nested button, the button isn't here. The 24x24 button that appears comes from another view on the same screen, noting the ample y coordinate from the parent image view.
Request:
Request that Apple, in the spirit of XCUI framework being to be near to human experience include this common design case
Several of our UI tests started failing when we switched over to M2 Macs...
The issue with the affected tests seems to be that have a element.swipeLeft() in them, the swipeLeft doesn't seem to work the same...
Is there a fix to the swipeLeft() issue yet?
If not, is there an easy way to programmatically test if we are running on an Apple Silicon Mac?
Any other ideas?
Thank you!
I'm having problems with UI tests on an M1 runner using Xcode 14.3.1. In my project, I need to build using the Rosetta simulator because I have a dependency that is not updated to support the arm simulator. This dependency relies on OpenCV."
This is the command that I use when I want to run UI tests on CI:
xcodebuild ARCHS=x86_64 clean test
-scheme UITests
-configuration Debug
-destination 'id=50E9C593-9A40-4E4D-B58D-1DE437CFBE3A'
-parallel-testing-enabled YES
-parallel-testing-worker-count 3
-maximum-concurrent-test-simulator-destinations 4
-test-iterations 3
-retry-tests-on-failure
And this code run only with 1 clone of simulator. Anyone know why?
I have setup and verified a sandbox account for testing.
I have received both email and text verification and received the email noting that the account has been enabled for two-factor.
Yet I receive the error below on both iOS and macOS devices.
Can someone shed some light on this matter?
Thanks!
Steve
iTunes Account creation not allowed
This Apple ID cannot be used with the iTunes Store at this time. Please try again later
I have some view which contents I want to interact with in UI test. In the first case, when view is added to view controller everything is fine - I can access all its contents. However, when the same view is added to table view cell, some of its content become unaccessible.
Here is view example
class SomeView: UIView {
required init?(coder: NSCoder) {
fatalError()
}
override init(frame: CGRect) {
super.init(frame: frame)
let label = UILabel(frame: .init(x: 5, y: 5, width: 100, height: 20))
label.text = "Label"
label.accessibilityIdentifier = "label"
addSubview(label)
let button = UIButton(frame: .init(x: 5, y: 35, width: 100, height: 20))
button.setTitle("Button", for: .normal)
button.accessibilityIdentifier = "button"
button.setTitleColor(.black, for: .normal)
addSubview(button)
let view = UIView(frame: .init(x: 5, y: 65, width: 100, height: 20))
view.backgroundColor = .red
view.accessibilityIdentifier = "container"
addSubview(view)
let view2 = UIView(frame: .init(x: 0, y: 0, width: 100, height: 20))
view2.backgroundColor = .red
view2.accessibilityIdentifier = "inner_view"
view.addSubview(view2)
let label2 = UILabel(frame: .init(x: 0, y: 0, width: 100, height: 20))
label2.text = "Label2"
label2.accessibilityIdentifier = "inner_label"
view2.addSubview(label2)
accessibilityIdentifier = "some_view"
}
}
And output from UI test
Attributes: Application, 0x7fb4b9d0e680, pid: 71041, label: 'UITest'
Element subtree:
→Application, 0x7fb4b9d0e680, pid: 71041, label: 'UITest'
Window (Main), 0x7fb4b9d0ae20, {{0.0, 0.0}, {390.0, 844.0}}
Other, 0x7fb4b9b08bc0, {{0.0, 0.0}, {390.0, 844.0}}
Other, 0x7fb4b9b0b040, {{0.0, 0.0}, {390.0, 844.0}}
Other, 0x7fb4b9b0ac80, {{0.0, 0.0}, {390.0, 844.0}}
Other, 0x7fb4b9b09960, {{0.0, 50.0}, {200.0, 100.0}}, identifier: 'some_view'
StaticText, 0x7fb4b9b0ec80, {{5.0, 55.0}, {100.0, 20.0}}, identifier: 'label', label: 'Label'
Button, 0x7fb4b9b10770, {{5.0, 85.0}, {100.0, 20.0}}, identifier: 'button', label: 'Button'
StaticText, 0x7fb4b9b0bbf0, {{28.0, 84.0}, {54.0, 22.0}}, label: 'Button'
Other, 0x7fb4b981b1d0, {{5.0, 115.0}, {100.0, 20.0}}, identifier: 'container'
Other, 0x7fb4b981b2e0, {{5.0, 115.0}, {100.0, 20.0}}, identifier: 'inner_view'
StaticText, 0x7fb4b981c0d0, {{5.0, 115.0}, {100.0, 20.0}}, identifier: 'inner_label', label: 'Label2'
Table, 0x7fb4b981c1e0, {{16.0, 343.0}, {361.0, 244.0}}
Cell, 0x7fb4b981c2f0, {{16.0, 343.0}, {361.0, 100.0}}
StaticText, 0x7fb4b981c420, {{21.0, 348.0}, {100.0, 20.0}}, identifier: 'label', label: 'Label'
StaticText, 0x7fb4b981c530, {{21.0, 408.0}, {100.0, 20.0}}, identifier: 'inner_label', label: 'Label2'
Button, 0x7fb4b981c640, {{21.0, 378.0}, {100.0, 20.0}}, identifier: 'button', label: 'Button'
StaticText, 0x7fb4b981c750, {{44.0, 377.0}, {54.0, 22.0}}, label: 'Button'
Other, 0x7fb4b981c860, {{16.0, 343.0}, {361.0, 100.0}}
Other, 0x7fb4b981c970, {{16.0, 343.0}, {361.0, 100.0}}
Other, 0x7fb4b9b05400, {{36.0, 442.7}, {341.0, 0.3}}
Path to element:
→Application, 0x7fb4b9d0e680, pid: 71041, label: 'UITest'
Query chain:
→Find: Target Application 'com.temp.temp.UITest'
Output: {
Application, 0x7fb4b981ce80, pid: 71041, label: 'UITest'
}
As you can see, in table view I am missing some_view, container and inner_view views. Is there a way to access these elements in table view?