diff --git a/xcuitest-sample-proj.xcodeproj/project.xcworkspace/xcuserdata/shamanec.xcuserdatad/UserInterfaceState.xcuserstate b/xcuitest-sample-proj.xcodeproj/project.xcworkspace/xcuserdata/shamanec.xcuserdatad/UserInterfaceState.xcuserstate index c7afee4..ae811fb 100644 Binary files a/xcuitest-sample-proj.xcodeproj/project.xcworkspace/xcuserdata/shamanec.xcuserdatad/UserInterfaceState.xcuserstate and b/xcuitest-sample-proj.xcodeproj/project.xcworkspace/xcuserdata/shamanec.xcuserdatad/UserInterfaceState.xcuserstate differ diff --git a/xcuitest-sample-proj/AppDelegate.swift b/xcuitest-sample-proj/AppDelegate.swift index e29ea24..aac8aab 100644 --- a/xcuitest-sample-proj/AppDelegate.swift +++ b/xcuitest-sample-proj/AppDelegate.swift @@ -28,27 +28,50 @@ struct TabBarView: View { .tabItem { Label("Loading", systemImage: "star") } - - DisappearButtonView() - .tabItem { - Label("Disappear", systemImage: "star") - } } } } struct CarouselView: View { + @State private var isButtonVisible = true + var body: some View { - ScrollView(.horizontal) { - LazyHStack(spacing: 16) { - ForEach(1...10, id: \.self) { index in - // Load each carousel item lazily - CarouselItemView(item: index) + VStack { + ScrollView(.horizontal) { + LazyHStack(spacing: 16) { + ForEach(1...10, id: \.self) { index in + // Load each carousel item lazily + CarouselItemView(item: index) + } + } + .padding() + .frame(height: 150) + } + .accessibilityIdentifier("carousel-view") + + VStack { + if isButtonVisible { + Button("Disappearing button") { + // Handle the action when the button is tapped + hideButtonAfterDelay() + } + .foregroundColor(.white) + .padding() + .frame(width: 200, height: 50) + .background(Color.blue) + .cornerRadius(12) + .accessibilityIdentifier("disappearing-button") } } - .padding() } - .accessibilityIdentifier("carousel-view") + + } + + private func hideButtonAfterDelay() { + // Set the button visibility to false after 5 seconds + DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) { + isButtonVisible = false + } } } @@ -76,32 +99,3 @@ struct LoadingElementsView: View { } } } - -struct DisappearButtonView: View { - @State private var isButtonVisible = true - - var body: some View { - VStack { - if isButtonVisible { - Button("Disappearing button") { - // Handle the action when the button is tapped - hideButtonAfterDelay() - } - .foregroundColor(.white) // Text color - .padding() - .frame(width: 200, height: 50) // Set exact width and height - .background(Color.blue) // Button background color - .cornerRadius(12) // Rounded re - .accessibilityIdentifier("disappearing-button") - } - } - .padding() - } - - private func hideButtonAfterDelay() { - // Set the button visibility to false after 5 seconds - DispatchQueue.main.asyncAfter(deadline: .now() + 5.0) { - isButtonVisible = false - } - } -} diff --git a/xcuitest-sample-projUITests/xcuitest_sample_projUITests.swift b/xcuitest-sample-projUITests/xcuitest_sample_projUITests.swift index b464ab2..59c3807 100644 --- a/xcuitest-sample-projUITests/xcuitest_sample_projUITests.swift +++ b/xcuitest-sample-projUITests/xcuitest_sample_projUITests.swift @@ -10,6 +10,7 @@ import XCTest final class xcuitest_sample_projUITests: Base { func testGentleSwipeUntil() { + print(app.debugDescription) InteractionHelper.performGentleSwipeUntil(app.scrollViews["carousel-view"], .left, 5, until: app.staticTexts["carousel_item10"].exists) } @@ -30,14 +31,16 @@ final class xcuitest_sample_projUITests: Base { func testElementDisappearsSameScreen() { app.buttons["Disappear"].tap() let disappearingButton = app.buttons.element(matching: .button, identifier: "disappearing-button") + XCTAssertTrue(disappearingButton.isVisible) disappearingButton.tap() ElementsHelper.waitUntilElementDisappears(element: disappearingButton, timeoutValue: 6) + XCTAssertFalse(disappearingButton.isVisible) } func testElementNotExistChangeScreens() { app.buttons["Disappear"].tap() let button = app.buttons.element(matching: .button, identifier: "disappearing-button") - XCTAssertTrue(button.exists) + XCTAssertTrue(button.isVisible) app.buttons["Carousel"].tap() XCTAssertFalse(button.exists) } @@ -45,10 +48,8 @@ final class xcuitest_sample_projUITests: Base { func testWaitForQueryHaveNumberOfElements() { app.buttons["Loading"].tap() let elements = app.staticTexts.matching(identifier: "loaded-el") - // Wait default timeout to have at least 1 element, should pass - ElementsHelper.waitUntilTableFilled(elements: elements) - // Wait for 10 seconds to have 5 elements, should pass - ElementsHelper.waitUntilTableFilled(elements: elements, 5, TestConstants.Timeout.medium) + // Wait for 11 seconds to have 5 elements, should pass + ElementsHelper.waitUntilTableFilled(elements: elements, 11, TestConstants.Timeout.medium) // Wait 5 more seconds to have 6 elements, should fail because only 5 in total will be loaded ElementsHelper.waitUntilTableFilled(elements: elements, 6, TestConstants.Timeout.short) }