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?
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
We run our UI tests in parallel on 3 simulators, and I noticed, that the first one starts executing tests way faster then the rest (because others are still booting, I guess). Also we have our backend server running locally which is used in UI tests. And here comes the problem - I noticed that tests on first simulator are often failing because of the problems with local backend(requests take much more time than usual) exactly in period when other simulators are still booting(tests stop failing when all 3 simulators started running tests). When I tried running tests without parallel simulators problems with backend disappear. So my guess is that simulators booting they take some resources(CPU, memory) which interferes with backend. So my question is there some way to start executing tests only when all parallel simulators are booted?
I get this error from time to time in UI tests when they are run on CI. Any ideas what might be causing this error?
Hi! I develop an iOS library and I met an issue with SwiftUI previews in iOS app project with my library integrated. After I open preview, build for preview finishes successfully, but preview itself never appears. I failed to find any error messages or any other indicators of what went wrong or how to fix it. Switching to legacy preview execution seems to fix problem, but I think that is not ideal. Could you help fixing this?
Xcode 16.2, Simulator iPhone 16, iOS 18.2
Project to reproduce -
https://drive.google.com/file/d/1cU6JKwshK_wQfe9YIqcMg3UGWq45OYlx/view?usp=sharing
Preview diagnostics - https://drive.google.com/file/d/1kPcgVSSqreiepGuqhdIoCW2rLSicgsWr/view?usp=sharing
I have an swift command line tool that changes proxy settings in system preferences via SystemConfiguration framework, does some stuff, and in the end reverts proxy settings back to original.
Here is simplified code:
var authorization: AuthorizationRef?
let status = AuthorizationCreate(nil, nil, [], &authorization)
let prefs = SCPreferencesCreateWithAuthorization(nil, "myapp" as CFString, nil, authorization)
// change proxy setttings
// do some stuff
let prefs2 = SCPreferencesCreateWithAuthorization(nil, "myapp" as CFString, nil, authorization)
// change proxy settings back to original
When I try to change settings for the first time, the system dialog appears requesting permission to change network settings. If I try to change settings again within а short period of time, the dialog does not appear again. However, if it takes more than several minutes after first change, the dialog does appear again. Is there a way to create authorization, so that the dialog appears only once per app launch, no matter how much time passed since the first dialog?