skip to Main Content

We have started adopting a new version of Xcode 14, and we see many tests failure. Many test failures are mainly those with a web view inside the app. After trying all the different alternatives, we cannot tap on the done button; that’s the default button when we open the web view in the app.

Please list the steps you took to reproduce the issue:
Our tests are trying tap on done button that’s inside the web view and seeing error (default done button of browsers). We can check the existence of the button that’s return true but can’t tap on it . see attachment

that’s Xcode 14 bug for sure. I also tested previous version of Xcode 13.4.1 and did not see any error

Any alternative way to handle the webview done button

enter image description here

3

Answers


  1. Chosen as BEST ANSWER
    extension XCUIApplication {
    
        func tapCoordinate(at point: CGPoint) {
             let normalized = coordinate(withNormalizedOffset: .zero)
             let offset = CGVector(dx: point.x, dy: point.y)
             let coordinate = normalized.withOffset(offset)
             coordinate.tap()
         }
    
    }
    

    with help from How to tap on a specific point using Xcode UITests


  2. @Nish answer works fine, so I added a little variation to get the coordinate of the button and tap on it.
    (Note: this will work on any screen/simulator size, because it is not dependent on the CGPoint being explicitly passed)

    if let doneButton = app.buttons["Done"].waitAndHandleFailure(timeout: JourniTestConstants.asyncTimeout) {
            let doneCoordinates = app.coordinate(withNormalizedOffset: .zero).withOffset(.init(dx: doneButton.frame.midX, dy: doneButton.frame.midY))
            doneCoordinates.tap()
        }
    
    Login or Signup to reply.
  3. Something that helped me was:

    App.shared.buttons["Done"].coordinate(
            withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search