-
Notifications
You must be signed in to change notification settings - Fork 71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Help needed: BackItem broken for UITests #35
Comments
Which version are you using? |
My podlock file shows |
Can I have a look at your code? |
Sure. In my private func setupNavigationBar() {
self.navigation.configuration.isEnabled = true
self.navigation.configuration.titleTextAttributes = [
.foregroundColor: Colour.text
]
self.navigation.configuration.barTintColor = Colour.layer1
self.navigation.configuration.isTranslucent = false
self.navigation.configuration.isHidden = true
self.navigation.configuration.backItem = UINavigationController
.Configuration
.BackItem(style: .image(Image.back),
tintColor: Colour.text)
} The homepage has private fund setupNavigationBar() {
self.navigation.bar.isHidden = false
self.navigation.bar.prefersLargeTitles = false
self.navigation.item.largeTitleDisplayMode = .never
self.navigation.bar.additionalHeight = 20
// acts as a bit of a skirt to keep the label off the bottom of the nav bar
let navFooter = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 18))
navFooter.backgroundColor = Colour.layer1
self.navigation.bar.additionalView = navFooter
// title
let label = UILabel(frame: .zero)
label.text = "Explore"
label.font = Fonts.h2
self.navigation.item.leftBarButtonItem = UIBarButtonItem(customView: label)
// search button
let imageview = UIImageView()
imageview.image = Image.search.withRenderingMode(.alwaysTemplate)
imageview.tintColor = Colour.text
let searchButton = UIButton(type: .custom)
searchButton.addTarget(buttonTarget, action: buttonSelector, for: .touchUpInside)
searchButton.addSubview(imageview)
searchButton.accessibilityIdentifier = "nav_button"
// snapkit constraints
imageview.snp.makeConstraints { (make) in
make.width.height.equalTo(24)
make.left.right.equalToSuperview()
make.top.bottom.equalToSuperview().inset(10)
}
self.navigation.item.rightBarButtonItem = UIBarButtonItem(customView: searchButton)
} Before the next view controller is pushed, I call trendingViewController.navigationItem.title = "Trending" then in self.navigation.bar.prefersLargeTitles = true
self.navigation.item.largeTitleDisplayMode = .always Then, my UI tests goes something like this let app = XCUIApplication()
// tap cell to get into view controller
// test element exists
app.navigationBars.buttons.element(boundBy: 0).tap() // <-- fails Thanks |
navigation.bar.backBarButtonItem = .init(style: .image(image)) Try using it in trendingViewController |
Sadly not made any difference. Putting a breakpoint in my test, when I type into the console po app.navigationBars.buttons I get the following output
I'm sure you'll know better than me, but I think it a bit weird there are two buttons, one which says "Back". Either way, when doing either |
Since bringing this (fantastic) library in, my UI test has failed when trying to press the back button in the navigation bar. Do you know if there is a trick to getting it tappable at all?
I used to have
app.navigationBars.buttons.element(boundBy: 0).tap()
, but that is now failing withAny help appreciated.
Thanks a lot
Luke
The text was updated successfully, but these errors were encountered: