View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vidéos

Ouvrir le menu Fermer le menu
  • Collections
  • Toutes les vidéos
  • À propos

Plus de vidéos

  • À propos
  • Code
  • Explore Digital Crown, Trackpad, and iPad pointer automation

    Learn how you can interact with devices in UI Tests in Xcode 13. Discover newly-automatable input methods including iPadOS pointer, watchOS Digital Crown, and enhanced macOS trackpad scrolling APIs.

    Ressources

      • Vidéo HD
      • Vidéo SD

    Vidéos connexes

    WWDC21

    • Diagnose unreliable code with test repetitions
    • Embrace Expected Failures in XCTest
  • Rechercher dans cette vidéo…
    • 1:28 - New supportsPointerInteraction property on XCUIDevice

      extension XCUIDevice {
      
        public var supportsPointerInteraction: Bool
      
      }
    • 1:37 - New methods on XCUIElement and XCUICoordinate for pointer interactions on iOS

      extension XCUIElement {
        open func hover()
      
        open func click()
      
        open func rightClick()
      
        open func doubleClick()
      
        open func scroll(byDeltaX: CGFloat, deltaY: CGFloat)
      
        open func click(forDuration: TimeInterval, thenDragToElement: XCUIElement)
      
        open func click(forDuration: TimeInterval, thenDragToElement: XCUIElement,
                        withVelocity: XCUIGestureVelocity, thenHoldForDuration: TimeInterval)
      
        open class func perform(withKeyModifiers flags: XCUIElement.KeyModifiers,
                                block: () -> Void)
      }
    • 2:31 - Empty UI test class

      import XCTest
      
      class Pointer_UI_Tests: XCTestCase {
      
      
      
      }
    • 2:43 - UI test for opening the sidebar with a two-finger horizontal trackpad swipe

      import XCTest
      
      class Pointer_UI_Tests: XCTestCase {
      
        @available(iOS 15.0, *)
        func testHorizontalScrollRevealsSidebar() throws {
          let app = XCUIApplication()
          app.launch()
      
          let sidebar = app.tables["Sidebar"]
      
          // Make sure sidebar menu is not present initially.
          XCTAssertFalse(sidebar.exists, "Sidebar should not be present initially")
      
          // Swipe horizontally to reveal sidebar.
          app.staticTexts["Select a smoothie"].scroll(byDeltaX: -200, deltaY: 0)
      
          // Verify sidebar is now present.
          XCTAssertTrue(sidebar.waitForExistence(timeout: 5),
                        "Sidebar did not appear within 5 second timeout")
        }
      
      }
    • 4:36 - Use the new supportsPointerInteraction property to skip the test on devices that don't support pointer interaction

      import XCTest
      
      class Pointer_UI_Tests: XCTestCase {
      
        @available(iOS 15.0, *)
        func testHorizontalScrollRevealsSidebar() throws {
          try XCTSkipUnless(XCUIDevice.shared.supportsPointerInteraction,
                            "Device does not support pointer interaction")
      
          let app = XCUIApplication()
          app.launch()
      
          let sidebar = app.tables["Sidebar"]
      
          // Make sure sidebar menu is not present initially.
          XCTAssertFalse(sidebar.exists, "Sidebar should not be present initially")
      
          // Swipe horizontally to reveal sidebar.
          app.staticTexts["Select a smoothie"].scroll(byDeltaX: -200, deltaY: 0)
      
          // Verify sidebar is now present.
          XCTAssertTrue(sidebar.waitForExistence(timeout: 5),
                        "Sidebar did not appear within 5 second timeout")
        }
      
      }
    • 5:27 - New method on XCUIDevice for Digital Crown rotation on watchOS

      // New rotateDigitalCrown API
      
      extension XCUIDevice {
      
        open func rotateDigitalCrown(delta: CGFloat, velocity: XCUIGestureVelocity = .default)
      
      }
    • 6:22 - UI test to verify the app's Digital Crown rotation functionality behaves as expected

      // Example use of watchOS Digital Crown API
      
      func testForecastScrolling() {
        let app = XCUIApplication()
        app.launch()
      
        let forecastTime = app.staticTexts["forecast-time"]
      
        XCTAssertEqual(forecastTime.label, "Current Temperature")
      
        // Scroll 1 full rotation forward.
        XCUIDevice.shared.rotateDigitalCrown(delta: 1.0)
        XCTAssertEqual(forecastTime.label, "One hour from now")
      
        // Scroll 2 full rotations backward.
        XCUIDevice.shared.rotateDigitalCrown(delta: -2.0)
        XCTAssertEqual(forecastTime.label, "One hour ago")
      }
    • 7:46 - Existing API for performing discrete (mouse wheel-like) scrolling on macOS

      extension XCUIElement {
      
        // Use the existing API for discrete (mouse wheel-like) scrolling.
        open func scroll(byDeltaX: CGFloat, deltaY: CGFloat)
      
      }
    • 8:05 - New API for performing continuous (trackpad-like) scrolling on macOS

      extension XCUIElement {
      
        // Use the new API for continuous (trackpad-like) scrolling.
        open func swipeUp(velocity: XCUIGestureVelocity = .default)
        open func swipeDown(velocity: XCUIGestureVelocity = .default)
        open func swipeLeft(velocity: XCUIGestureVelocity = .default)
        open func swipeRight(velocity: XCUIGestureVelocity = .default)
      
      }

Developer Footer

  • Vidéos
  • WWDC21
  • Explore Digital Crown, Trackpad, and iPad pointer automation
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines