with the same issue.
https://developer.apple.com/forums/thread/100501
I am running xucitest framework, for e2e testing.
And webdriver app is running background, so it could't get clipboard while my tested app in running in front.
I could't switch app to get clipboard, because it will refresh my app.
Is there any way to allow clipboard permission with webdriver ?
XCTest
RSS for tagCreate and run unit tests, performance tests, and UI tests for your Xcode project using XCTest.
Posts under XCTest tag
145 Posts
Sort by:
Post
Replies
Boosts
Views
Activity
I know, for secure reason, apple forbidden app the ability to get clipboard data in background.
But in some case, for example, i use appium to e2e testing my real device. And I could't get clipboard from webdriver. Because it's running background!
So, it's there any way to get clipboard from webdriver? It bothers me.
let metrics: [XCTMetric] = [XCTClockMetric(), // to measure time
XCTCPUMetric(), // to measure cpu cycles
XCTStorageMetric(), // to measure storage consuming
XCTMemoryMetric(),
]
let measureOptions = XCTMeasureOptions.default
measureOptions.iterationCount = 1
measure(metrics: metrics) {
//App flow
}
I want to get values of XCTCPUMetric, XCTMemoryMetric, XCTStorageMetric etc in any variable so that if want to send it further somewhere I can do it.
Example -
// let cpuMetric = CPU measure object should be here & I can get each information from this object.
// let MemoryMetric = Memory measure object should be here & I can get each information from this object.
But It's not available in XCUITest. We can only able to find it in the TestResult file. Please suggest any code available to get each metric object & value in the XCUITest rather than the test result.
`
let metrics: [XCTMetric] = [XCTClockMetric(), // to measure time
XCTCPUMetric(), // to measure cpu cycles
XCTStorageMetric(), // to measure storage consuming
XCTMemoryMetric(),
]
let measureOptions = XCTMeasureOptions.default
measureOptions.iterationCount = 1
measure(metrics: metrics) {
//App flow
}
`
I want to get values of XCTCPUMetric, XCTMemoryMetric, XCTStorageMetric etc in any variable so that if want to send it further somewhere I can do it.
Example -
// let cpuMetric = CPU measure object should be here & I can get each information from this object.
// let MemoryMetric = Memory measure object should be here & I can get each information from this object.
But It's not available in XCUITest. We can only able t find it in the TestResult file.
Please suggest any code available to get each metric object & value in the XCUITest rather than the test result.
Hi all,
I have a UI Automation Test suite with a large number of test cases, that typically takes me 7 hours to run. When I setup the workflow on XCode cloud, I received the following error - "Build has exceeded the maximum allotted time. Each build can run for up to 120 minutes. If a build has not yet finished at this time, all incomplete actions will be cancelled."
Is there any way to extend the build time?
What is a build? I have two actions in my workflow. Build Action (that took 3 minutes) and the test step that took 2 hour 4 minutes. Am not clear how the 120 minute window is calculated.
While using XCTest with Appium Inspector for iOS 18 on the "Select Contacts" screen, I expected XCTest to identify XCUIElement references for both the "Allow All Access" and "Select Contacts" buttons. However, neither element was found in the results and also there is no reference to any text in screen.
Feedback Assistant tag = FB14622782
I'm using the following code to launch a UI test that forces a specific app language and moves a slider.
I noticed that when forcing right to left text direction (for Arabic or Hebrew), during the UI test the slider doesn't move.
The app content:
struct ContentView: View {
@State private var slider = 0.0
var body: some View {
Slider(value: $slider, in: 0.0...1.0)
}
}
The UI test:
final class problemUITests: XCTestCase {
func testExample() throws {
let app = XCUIApplication()
let locale = Locale(identifier: "ar")
app.launchArguments += ["-AppleLanguages", "(ar)", "-AppleLocale", "ar"]
if locale.language.characterDirection == .rightToLeft {
app.launchArguments += ["-NSForceRightToLeftWritingDirection", "YES", "-AppleTextDirection", "YES"]
}
app.launch()
app.sliders.element.adjust(toNormalizedSliderPosition: 0.3)
}
}
Am I missing something or is there a workaround?
XCUIElement has two methods named typeKey(_:modifierFlags:): the first one takes a String as an argument, the second one a XCUIKeyboardKey, which has constants like .downArrow. Now, even if the documentation says that both methods are "Available in macOS and in iPadOS 15 and later", when compiling the UI tests for iOS, the following line
app.typeKey(.downArrow, modifierFlags: [])
produces a compiler error
Type 'String' has no member 'downArrow'
Am I missing something or is there a workaround?
I'm using Xcode Cloud for release builds and unit tests, and it works fine. Recently, I added some XCUITests, but to run it the way I need I started to use this mock server. Basically, the idea is you define before each test what responses you want to get for specific requests. It works like a charm locally. But if I want to run it in Xcode Cloud, it looks like the server has failed to launch. The mock server is a separately launched binary file. I think this is because this permission I get when launch it locally.
So, my question is how to allow this kind of permission in Xcode Cloud to make my UITests works correctly?
You can find a detailed instruction how server is launched on a github page I provided.
Apparently UI tests are unable to tap menu buttons but can tap regular buttons inside forms. Earlier today I was able to see in the Simulator that the UI test tries to tap the button by tapping the center of the containing form row, which works for regular buttons, but not for menu buttons. In fact, when trying in the SwiftUI preview in Xcode it seems that menu buttons have to be tapped exactly on top of them, while regular buttons can be tapped anywhere in the form row. (Now I’m not able to see touches performed by the UI test anymore in the Simulator for an unknown reason, even though I have “Show single touches” enabled in the Simulator settings.)
How can I open a menu button in a UI test?
The UI code:
struct ContentView: View {
@State private var label1 = "Menu 1"
@State private var label2 = "Menu 2"
var body: some View {
NavigationStack {
Form {
LabeledContent("Menu 1") {
Button(label1) {
label1 = "Menu 1 tapped"
}
.accessibilityIdentifier("menu1")
}
LabeledContent("Menu 2") {
Menu(label2) {
Button("Button") {
}
.accessibilityIdentifier("button")
}
.accessibilityIdentifier("menu2")
}
}
}
}
}
#Preview {
ContentView()
}
And the test:
final class problemUITests: XCTestCase {
func testExample() throws {
// UI tests must launch the application that they test.
let app = XCUIApplication()
app.launch()
app.collectionViews.element(boundBy: 0).buttons["menu1"].tap()
app.collectionViews.element(boundBy: 0).buttons["menu2"].tap()
app.collectionViews.element(boundBy: 0).buttons["button"].tap()
}
}
I have a few UI Tests in my app, and some of them access the tab bar, for instance: XCUIApplication().tabBars.element.buttons.element(boundBy: tabBarButtonCount - 1).tap()
In Xcode 16 though, when performing tests on iPad, this fails, likely due to the new tab bar. How am I supposed to perform this kind of action in iPadOS 18?
That's probably a bad title, let's try with specifics: we have a network extension, it has some classes / functions of its own, and they, when push comes to build, depend on (for example) NEAppProxyFlow and its subclasses. The code is written in Swift, since it is the language of the future.
If I want to do a unit test for my code, I need to provide something that at least looks like NEAppProxyFlow, since I can't otherwise create one. I thought I could provide my own NetworkExtension module for test case, but that... did not work well, and I still don't understand why.
On the other hand, I'm really bad at making unit tests, so the odds that I'm missing something fairly obvious to most other people are pretty high.
We are using the XCUITest Framework in one of our Apple TV Application. We have created test plans and using Jenkins for CI-CD. Once the test execution is completed, then it gets stuck and it is not stopping/completing the execution by itself.
Hello,
I am developing Java test code to test a web application on an Android and iPhone platforms using Selenium and Appium inside Eclipse IDE. Android device could be tested just fine. When it comes to instantiation of iOSDriver Object for running test script on an iPhone, the run time is complaining that it needs Xcode libraries, or Xcode tool on the class path. This makes it necessary to use a mac system for coding and install Xcode on it.
Once I use a mac and develop the test code within my Eclipse, can I deploy the code on a Windows Server? Does the code would not need Xcode during run time or just the Selenium-java client libraries and Appium alone?
Thanks a lot,
-- Prasad Nutalapati
I’m writing UI tests for biometrics in iOS. For a failing case, I encounter an alert that needs to be dismissed by the user. How can I tap a button in this alert?
XCTest has the addUIInterruptionMonitor method (https://developer.apple.com/documentation/xctest/xctestcase/1496273-adduiinterruptionmonitor). Is this what I need? If so, what description should I use? Or do I need some other functionality?
For Touch ID, I can simply simulate a failure twice, and the alert will be dismissed. However, for Face ID and Optic ID, this approach is not suitable—the alert buttons need to be tapped. Additionally, there is an old method to handle the alert using the Springboard app (with the bundle ID “com.apple.springboard”). However, this only works for iOS and iPadOS, while VisionOS does not have this bundle ID.
I want to automate tests for my iOS app and start writing UITests.
Sometimes system alerts appear, and my tests have to simulate button tapping.
In iOS and iPadOS these alerts are available via the system Springboard application:
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
let cancelButton = springboard.alerts.buttons["Cancel"].firstMatch
if cancelButton.exists {
cancelButton.tap() // <-- cancel button taps, and test continue working
}
But when I launch my test in the Vision Pro simulator, the springboard is not available:
let springboard = XCUIApplication(bundleIdentifier: "com.apple.springboard")
print(springboard.exists) // <-- "false" will be printed, springboard does not exist
It means that I can't automate button tapping in system alerts.
So, my question is:
How can I access system alerts in VisionOS and tap buttons by UITests?
We have multiple Jenkins jobs running UI Tests on a Mac with a device attached.
This works most of the time but sometimes the tests don't run and the xcreport generated has an error like:
BCOVBRDCoverageUITests-Runner encountered an error in BCOVBRDCoverageUITests failed with:
Failed to install or launch the test runner. (Underlying Error: Failed to create directory on device 'Brightcove's iPhone 14 Plus' (00008110-000C54912246401E) to hold runtime profiles for application with bundle ID 'com.brightcove.BCOVBRDCoverageUITests.xctrunner': (null). (Underlying Error: The system failed to get the path on the remote device for the provided domain. (Underlying Error: The connection was interrupted.)))
Has anyone else run into this? Any ideas on how to get around it? Kicking off another job after seeing this behavior works fine. The failures seem to be random or we haven't noticed a pattern yet.
I am able to reproduce this also in a minimal example.
Here is my setup:
a Hello World app and a UI test target.
a Test Plan which executes the UI test target
test plan configures application language as German for sanity testing whether changing the test configuration via the test plan in general works -> this works perfectly
test plan configures launch arguments and Environment variables in the shared settings "Arguments passed on launch"
In the ContentView of the app I try to access these values via ProcessInfo:
print(ProcessInfo.processInfo.arguments)
print(ProcessInfo.processInfo.environment)
Now I run the test plan
Expected:
my custom launch arguments appear in arguments
my custom env vars appear in environment
Actual: none of them appear.
What am I doing wrong here?
Hello,
I have a test bundle in my application and one of the strong request of our project is to run ui tests from command line having just application build.
How to run unit tests on .app file that has a test target?
What we tried
xcrun devicectl device install app --device <device-identifier> <UITestBundle-Runner.app>
xcrun devicectl device process launch --device <device-identifier> --start-stopped <com.apptestbundle-Runner.xcrun>
It launches and is waiting pid to be attached.
In lldb:
device select <device-identifier>
device process list
Seeing process 'UITestBundle-Runner' pid.
device process --pid 'pid id'
It attaches and I can see 'debugserver' in the pid list, but it does not start testing and I need tests to start and run.
Thanks!
We currently try to run tests on 4 physically attached iPhones all on ios 17. When tests are concurrently running we occasionally get failures that look like this:
Testing failed:
Failed to install the app on the device.
SwiftUITests-Runner encountered an error (Failed to install or launch the test runner. (Underlying Error: Failed to install the app on the device. (Underlying Error: Connection with the remote side was unexpectedly closed : { count = 1, transaction: 0, voucher = 0x0, contents =
"XPCErrorDescription" => { length = 22, contents = "Connection interrupted" }
}. Unhandled error domain IXRemoteErrorDomain, code 6))
I noticed that when relying on xcodebuild to install the target app and test runner it cannot install concurrently/parallel on all 4 devices but instead does each device sequentially causing the test to hang. The same behavior can be exhibited when trying to install an app concurrently on 4 different phones with xcrun devicectl as well.
STEPS TO REPRODUCE
Trigger a test with xcodebuild on 4 different phones at the same time where xcodebuild also needs to install the target apps.
Currently using Xcode15.2 and iOS 17.5.1