代码之家  ›  专栏  ›  技术社区  ›  Charlie S

xcode xcuitest xcui坐标不适用于按下和/或拖动

  •  2
  • Charlie S  · 技术社区  · 6 年前

        let app = XCUIApplication()
        let pointOfInterest = app.buttons["PointOfInterest1"]
        let coordinates: XCUICoordinate = app.coordinate(withNormalizedOffset: CGVector(dx: pointOfInterest.frame.origin.x, dy: pointOfInterest.frame.origin.y))
        // This does nothing:
        coordinates.press(forDuration: 3)
        // This selects the points of interest:
        pointOfInterest.press(forDuration: 3)
    

    这是Xcode的Xcuitest中的已知错误还是我创建的坐标不正确?

    1 回复  |  直到 6 年前
        1
  •  0
  •   Charlie S    6 年前

    let app = XCUIApplication()
    let pointOfInterest = app.buttons["PointOfInterest1"]
    let normalized = app.coordinate(withNormalizedOffset: CGVector(dx: 0, dy: 0))
    let coordinates: XCUICoordinate = normalized.coordinate(withNormalizedOffset: CGVector(dx: pointOfInterest.frame.origin.x, dy: pointOfInterest.frame.origin.y))
    // This now works:
    coordinates.press(forDuration: 3)
    // This selects the points of interest:
    pointOfInterest.press(forDuration: 3)