Add onboarding Next buttons and fix accessibility for paged TabView
App-side changes: - Added "Get Started" / "Continue" next buttons to all onboarding pages (Welcome, Day, Time, Style) with onboarding_next_button accessibility ID - Added onNext callback plumbing from OnboardingMain to each page - OnboardingMain now uses TabView(selection:) for programmatic page navigation - Added .accessibilityElement(children: .contain) to all onboarding pages to fix iOS 26 paged TabView not exposing child elements - Added settings_segmented_picker accessibility ID to Settings Picker - Reduced padding on onboarding pages to keep buttons in visible area Test-side changes: - OnboardingScreen: replaced unreliable swipeToNext() with tapNext() that taps the accessibility-identified next button - OnboardingScreen: multi-strategy skip button detection for subscription page - SettingsScreen: scoped segment tap to picker element to avoid tab bar collision - CustomizeScreen: simplified horizontal scroll to plain app.swipeLeft() - OnboardingVotingTests: uses tapNext() to advance to Day page Passing: OnboardingTests.CompleteFlow, OnboardingVotingTests Remaining: OnboardingTests.DoesNotRepeat (session state issue), Settings scroll (deep elements), Customize horizontal pickers Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -16,8 +16,7 @@ struct SettingsScreen {
|
||||
// MARK: - Elements
|
||||
|
||||
var settingsHeader: XCUIElement { app.element(UITestID.Settings.header) }
|
||||
var customizeSegment: XCUIElement { app.element(UITestID.Settings.customizeTab) }
|
||||
var settingsSegment: XCUIElement { app.element(UITestID.Settings.settingsTab) }
|
||||
var segmentedPicker: XCUIElement { app.element(UITestID.Settings.segmentedPicker) }
|
||||
var upgradeBanner: XCUIElement { app.element(UITestID.Settings.upgradeBanner) }
|
||||
var subscribeButton: XCUIElement { app.element(UITestID.Settings.subscribeButton) }
|
||||
var whyUpgradeButton: XCUIElement { app.element(UITestID.Settings.whyUpgradeButton) }
|
||||
@@ -30,42 +29,34 @@ struct SettingsScreen {
|
||||
// MARK: - Actions
|
||||
|
||||
func tapCustomizeTab(file: StaticString = #filePath, line: UInt = #line) {
|
||||
tapSegment(identifier: UITestID.Settings.customizeTab, fallbackLabel: "Customize", file: file, line: line)
|
||||
tapSegment(label: "Customize", file: file, line: line)
|
||||
}
|
||||
|
||||
func tapSettingsTab(file: StaticString = #filePath, line: UInt = #line) {
|
||||
tapSegment(identifier: UITestID.Settings.settingsTab, fallbackLabel: "Settings", file: file, line: line)
|
||||
tapSegment(label: "Settings", file: file, line: line)
|
||||
}
|
||||
|
||||
private func tapSegment(identifier: String, fallbackLabel: String, file: StaticString, line: UInt) {
|
||||
// On iOS 26, segmented controls may expose buttons by label or by ID.
|
||||
// Try multiple strategies in order of reliability.
|
||||
|
||||
// Strategy 1: Segmented control button by label (most reliable)
|
||||
let segButton = app.segmentedControls.buttons[fallbackLabel]
|
||||
if segButton.waitForExistence(timeout: defaultTimeout) && segButton.isHittable {
|
||||
segButton.tap()
|
||||
return
|
||||
}
|
||||
|
||||
// Strategy 2: Find a non-tab-bar button with matching label
|
||||
let tabBarButton = app.tabBars.buttons[fallbackLabel]
|
||||
let allButtons = app.buttons.matching(NSPredicate(format: "label == %@", fallbackLabel)).allElementsBoundByIndex
|
||||
for button in allButtons {
|
||||
if button.isHittable && button.frame != tabBarButton.frame {
|
||||
/// Tap a segmented control button by label, scoped to the settings picker
|
||||
/// to avoid collision with the tab bar's "Settings" button.
|
||||
private func tapSegment(label: String, file: StaticString, line: UInt) {
|
||||
// Find the segmented picker by its accessibility ID, then find the button within it
|
||||
let picker = segmentedPicker
|
||||
if picker.waitForExistence(timeout: defaultTimeout) {
|
||||
let button = picker.buttons[label]
|
||||
if button.waitForExistence(timeout: defaultTimeout) && button.isHittable {
|
||||
button.tap()
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Strategy 3: Accessibility ID with coordinate tap fallback
|
||||
let byID = app.element(identifier)
|
||||
if byID.waitForExistence(timeout: defaultTimeout) {
|
||||
byID.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.5)).tap()
|
||||
// Fallback: segmented control element type
|
||||
let segButton = app.segmentedControls.buttons[label]
|
||||
if segButton.waitForExistence(timeout: defaultTimeout) && segButton.isHittable {
|
||||
segButton.tap()
|
||||
return
|
||||
}
|
||||
|
||||
XCTFail("Could not find segment '\(fallbackLabel)' by ID or label", file: file, line: line)
|
||||
XCTFail("Could not find segment '\(label)' in settings picker", file: file, line: line)
|
||||
}
|
||||
|
||||
func tapClearData(file: StaticString = #filePath, line: UInt = #line) {
|
||||
@@ -79,8 +70,7 @@ struct SettingsScreen {
|
||||
}
|
||||
|
||||
/// Scroll within the settings content to find a deeply nested element.
|
||||
/// Uses aggressive swipes on the main app surface since the ScrollView
|
||||
/// hierarchy varies by iOS version.
|
||||
/// Swipes in the center band of the screen (between header and tab bar).
|
||||
private func scrollToSettingsElement(
|
||||
_ element: XCUIElement,
|
||||
maxSwipes: Int,
|
||||
@@ -90,9 +80,9 @@ struct SettingsScreen {
|
||||
if element.exists && element.isHittable { return }
|
||||
|
||||
for _ in 0..<maxSwipes {
|
||||
// Swipe up from center to scroll the settings content
|
||||
let start = app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.8))
|
||||
let end = app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.2))
|
||||
// Swipe from center-low to center-high, avoiding header area and tab bar
|
||||
let start = app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.7))
|
||||
let end = app.coordinate(withNormalizedOffset: CGVector(dx: 0.5, dy: 0.15))
|
||||
start.press(forDuration: 0.05, thenDragTo: end)
|
||||
|
||||
if element.exists && element.isHittable { return }
|
||||
|
||||
Reference in New Issue
Block a user