diff --git a/WordPress/UITestsFoundation/BaseScreen.swift b/WordPress/UITestsFoundation/BaseScreen.swift index 5abea3d9c376..bfd7a191c4cd 100644 --- a/WordPress/UITestsFoundation/BaseScreen.swift +++ b/WordPress/UITestsFoundation/BaseScreen.swift @@ -69,24 +69,8 @@ extension BaseScreen { } } - /// Scroll an element into view within another element. - /// scrollView can be a UIScrollView, or anything that subclasses it like UITableView - /// - /// TODO: The implementation of this could use work: - /// - What happens if the element is above the current scroll view position? - /// - What happens if it's a really long scroll view? public func scrollElementIntoView(element: XCUIElement, within scrollView: XCUIElement, threshold: Int = 1000) { - - var iteration = 0 - - while !element.isFullyVisibleOnScreen && iteration < threshold { - scrollView.scroll(byDeltaX: 0, deltaY: 100) - iteration += 1 - } - - if !element.isFullyVisibleOnScreen { - XCTFail("Unable to scroll element into view") - } + element.scrollIntoView(within: scrollView, threshold: threshold) } @discardableResult diff --git a/WordPress/UITestsFoundation/FancyAlertComponent.swift b/WordPress/UITestsFoundation/FancyAlertComponent.swift index 1c38d14f2f0e..9b618d2766ea 100644 --- a/WordPress/UITestsFoundation/FancyAlertComponent.swift +++ b/WordPress/UITestsFoundation/FancyAlertComponent.swift @@ -35,7 +35,7 @@ public class FancyAlertComponent: ScreenObject { defaultAlertButton.tap() } - func cancelAlert() { + public func cancelAlert() { cancelAlertButton.tap() } diff --git a/WordPress/UITestsFoundation/Globals.swift b/WordPress/UITestsFoundation/Globals.swift index 52c4177eaddc..38676543b988 100644 --- a/WordPress/UITestsFoundation/Globals.swift +++ b/WordPress/UITestsFoundation/Globals.swift @@ -36,4 +36,20 @@ extension ScreenObject { safari.scrollViews.element(boundBy: 0).buttons.element(boundBy: 1).tap() } } + + @discardableResult + public func dismissNotificationAlertIfNeeded( + _ action: FancyAlertComponent.Action = .cancel + ) throws -> Self { + guard FancyAlertComponent.isLoaded() else { return self } + + switch action { + case .accept: + try FancyAlertComponent().acceptAlert() + case .cancel: + try FancyAlertComponent().cancelAlert() + } + + return self + } } diff --git a/WordPress/UITestsFoundation/Screens/Editor/AztecEditorScreen.swift b/WordPress/UITestsFoundation/Screens/Editor/AztecEditorScreen.swift index 7711f4dc9564..c3bc0f888dd9 100644 --- a/WordPress/UITestsFoundation/Screens/Editor/AztecEditorScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Editor/AztecEditorScreen.swift @@ -209,7 +209,7 @@ public class AztecEditorScreen: BaseScreen { Select Image from Camera Roll by its ID. Starts with 0 Simulator range: 0..4 */ - func addImageByOrder(id: Int) -> AztecEditorScreen { + func addImageByOrder(id: Int) throws -> AztecEditorScreen { tapToolbarButton(button: mediaButton) // Allow access to device media @@ -221,7 +221,7 @@ public class AztecEditorScreen: BaseScreen { } // Inject the first picture - MediaPickerAlbumScreen().selectImage(atIndex: 0) + try MediaPickerAlbumScreen().selectImage(atIndex: 0) insertMediaButton.tap() // Wait for upload to finish diff --git a/WordPress/UITestsFoundation/Screens/Editor/BlockEditorScreen.swift b/WordPress/UITestsFoundation/Screens/Editor/BlockEditorScreen.swift index 1ec2b788bed9..1e4c34a476b5 100644 --- a/WordPress/UITestsFoundation/Screens/Editor/BlockEditorScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Editor/BlockEditorScreen.swift @@ -57,9 +57,9 @@ public class BlockEditorScreen: BaseScreen { /** Adds an image block with latest image from device. */ - public func addImage() -> BlockEditorScreen { + public func addImage() throws -> BlockEditorScreen { addBlock("Image block") - addImageByOrder(id: 0) + try addImageByOrder(id: 0) return self } @@ -126,14 +126,14 @@ public class BlockEditorScreen: BaseScreen { /* Select Image from Camera Roll by its ID. Starts with 0 */ - private func addImageByOrder(id: Int) { + private func addImageByOrder(id: Int) throws { imageDeviceButton.tap() // Allow access to device media app.tap() // trigger the media permissions alert handler // Inject the first picture - MediaPickerAlbumListScreen() + try MediaPickerAlbumListScreen() .selectAlbum(atIndex: 0) .selectImage(atIndex: 0) } diff --git a/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift b/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift index d2af02f39aa3..e342e99db834 100644 --- a/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift +++ b/WordPress/UITestsFoundation/Screens/Editor/EditorPostSettings.swift @@ -53,7 +53,7 @@ public class EditorPostSettings: ScreenObject { public func setFeaturedImage() throws -> EditorPostSettings { featuredImageButton.tap() - MediaPickerAlbumListScreen() + try MediaPickerAlbumListScreen() .selectAlbum(atIndex: 0) // Select media library .selectImage(atIndex: 0) // Select latest uploaded image diff --git a/WordPress/UITestsFoundation/Screens/Login/LoginEmailScreen.swift b/WordPress/UITestsFoundation/Screens/Login/LoginEmailScreen.swift index e95c764d7068..824784a5c021 100644 --- a/WordPress/UITestsFoundation/Screens/Login/LoginEmailScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Login/LoginEmailScreen.swift @@ -1,25 +1,26 @@ +import ScreenObject import XCTest // TODO: remove when unifiedAuth is permanent. -private struct ElementStringIDs { - static let emailTextField = "Login Email Address" - static let nextButton = "Login Email Next Button" - static let siteAddressButton = "Self Hosted Login Button" -} +public class LoginEmailScreen: ScreenObject { + + let emailTextFieldGetter: (XCUIApplication) -> XCUIElement = { + $0.textFields["Login Email Address"] + } -public class LoginEmailScreen: BaseScreen { - let emailTextField: XCUIElement - let nextButton: XCUIElement - let siteAddressButton: XCUIElement + let nextButtonGetter: (XCUIApplication) -> XCUIElement = { + $0.buttons["Login Email Next Button"] + } - init() { - let app = XCUIApplication() - emailTextField = app.textFields[ElementStringIDs.emailTextField] - nextButton = app.buttons[ElementStringIDs.nextButton] - siteAddressButton = app.buttons[ElementStringIDs.siteAddressButton] + var emailTextField: XCUIElement { emailTextFieldGetter(app) } + var nextButton: XCUIElement { nextButtonGetter(app) } - super.init(element: emailTextField) + init(app: XCUIApplication = XCUIApplication()) throws { + try super.init( + expectedElementGetters: [emailTextFieldGetter, nextButtonGetter], + app: app + ) } public func proceedWith(email: String) -> LinkOrPasswordScreen { @@ -31,18 +32,16 @@ public class LoginEmailScreen: BaseScreen { } func goToSiteAddressLogin() -> LoginSiteAddressScreen { - siteAddressButton.tap() + app.buttons["Self Hosted Login Button"].tap() return LoginSiteAddressScreen() } static func isLoaded() -> Bool { - let expectedElement = XCUIApplication().textFields[ElementStringIDs.emailTextField] - return expectedElement.exists && expectedElement.isHittable + (try? LoginEmailScreen().isLoaded) ?? false } static func isEmailEntered() -> Bool { - let emailTextField = XCUIApplication().textFields[ElementStringIDs.emailTextField] - return emailTextField.value != nil + (try? LoginEmailScreen().emailTextField.value != nil) ?? false } } diff --git a/WordPress/UITestsFoundation/Screens/Login/LoginSiteAddressScreen.swift b/WordPress/UITestsFoundation/Screens/Login/LoginSiteAddressScreen.swift index 33e0b51a0b67..9a6823b345c7 100644 --- a/WordPress/UITestsFoundation/Screens/Login/LoginSiteAddressScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Login/LoginSiteAddressScreen.swift @@ -25,12 +25,12 @@ public class LoginSiteAddressScreen: BaseScreen { super.init(element: siteAddressTextField) } - public func proceedWith(siteUrl: String) -> LoginUsernamePasswordScreen { + public func proceedWith(siteUrl: String) throws -> LoginUsernamePasswordScreen { siteAddressTextField.tap() siteAddressTextField.typeText(siteUrl) nextButton.tap() - return LoginUsernamePasswordScreen() + return try LoginUsernamePasswordScreen() } public func proceedWithWP(siteUrl: String) throws -> GetStartedScreen { diff --git a/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift b/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift index 1f6b0e5221f9..10fbd820f6a7 100644 --- a/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Login/LoginUsernamePasswordScreen.swift @@ -1,3 +1,4 @@ +import ScreenObject import XCTest import XCUITestHelpers @@ -16,18 +17,35 @@ private struct ElementStringIDs { static let nextButton = "Continue Button" } -public class LoginUsernamePasswordScreen: BaseScreen { - let usernameTextField: XCUIElement - let passwordTextField: XCUIElement - let nextButton: XCUIElement +public class LoginUsernamePasswordScreen: ScreenObject { - init() { - let app = XCUIApplication() - usernameTextField = app.textFields[ElementStringIDs.usernameTextField] - passwordTextField = app.secureTextFields[ElementStringIDs.passwordTextField] - nextButton = app.buttons[ElementStringIDs.nextButton] + let usernameTextFieldGetter: (XCUIApplication) -> XCUIElement = { + $0.textFields[ElementStringIDs.usernameTextField] + } + + let passwordTextFieldGetter: (XCUIApplication) -> XCUIElement = { + $0.secureTextFields[ElementStringIDs.passwordTextField] + } + + let nextButtonGetter: (XCUIApplication) -> XCUIElement = { + $0.buttons[ElementStringIDs.nextButton] + } + + var usernameTextField: XCUIElement { usernameTextFieldGetter(app) } + var passwordTextField: XCUIElement { passwordTextFieldGetter(app) } + var nextButton: XCUIElement { nextButtonGetter(app) } - super.init(element: passwordTextField) + init(app: XCUIApplication = XCUIApplication()) throws { + // Notice that we don't use the "next button" getter because, at the time the screen loads, + // that element is disabled. `ScreenObject` uses `isEnabled == true` on the elements we + // pass at `init`. + try super.init( + expectedElementGetters: [ + usernameTextFieldGetter, + passwordTextFieldGetter + ], + app: app + ) } public func proceedWith(username: String, password: String) -> LoginEpilogueScreen { @@ -47,6 +65,6 @@ public class LoginUsernamePasswordScreen: BaseScreen { } public static func isLoaded() -> Bool { - return XCUIApplication().buttons[ElementStringIDs.nextButton].exists + (try? LoginUsernamePasswordScreen().isLoaded) ?? false } } diff --git a/WordPress/UITestsFoundation/Screens/Login/WelcomeScreenLoginComponent.swift b/WordPress/UITestsFoundation/Screens/Login/WelcomeScreenLoginComponent.swift index ab22037ef88b..edec43edaa09 100644 --- a/WordPress/UITestsFoundation/Screens/Login/WelcomeScreenLoginComponent.swift +++ b/WordPress/UITestsFoundation/Screens/Login/WelcomeScreenLoginComponent.swift @@ -18,10 +18,10 @@ public class WelcomeScreenLoginComponent: BaseScreen { super.init(element: emailLoginButton) } - public func selectEmailLogin() -> LoginEmailScreen { + public func selectEmailLogin() throws -> LoginEmailScreen { emailLoginButton.tap() - return LoginEmailScreen() + return try LoginEmailScreen() } func goToSiteAddressLogin() -> LoginSiteAddressScreen { diff --git a/WordPress/UITestsFoundation/Screens/Media/MediaPickerAlbumListScreen.swift b/WordPress/UITestsFoundation/Screens/Media/MediaPickerAlbumListScreen.swift index b7ed89e2caee..6655051e5c3c 100644 --- a/WordPress/UITestsFoundation/Screens/Media/MediaPickerAlbumListScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Media/MediaPickerAlbumListScreen.swift @@ -1,24 +1,28 @@ +import ScreenObject import XCTest -public class MediaPickerAlbumListScreen: BaseScreen { - let albumList: XCUIElement +public class MediaPickerAlbumListScreen: ScreenObject { - public init() { - let app = XCUIApplication() - albumList = app.tables["AlbumTable"] + private let albumListGetter: (XCUIApplication) -> XCUIElement = { + $0.tables["AlbumTable"] + } - super.init(element: albumList) + public init(app: XCUIApplication = XCUIApplication()) throws { + try super.init( + expectedElementGetter: albumListGetter, + app: app + ) } - public func selectAlbum(atIndex index: Int) -> MediaPickerAlbumScreen { - let selectedAlbum = albumList.cells.element(boundBy: index) + public func selectAlbum(atIndex index: Int) throws -> MediaPickerAlbumScreen { + let selectedAlbum = albumListGetter(app).cells.element(boundBy: index) XCTAssertTrue(selectedAlbum.waitForExistence(timeout: 5), "Selected album did not load") selectedAlbum.tap() - return MediaPickerAlbumScreen() + return try MediaPickerAlbumScreen() } public static func isLoaded() -> Bool { - return XCUIApplication().tables["AlbumTable"].exists + (try? MediaPickerAlbumListScreen().isLoaded) ?? false } } diff --git a/WordPress/UITestsFoundation/Screens/Media/MediaPickerAlbumScreen.swift b/WordPress/UITestsFoundation/Screens/Media/MediaPickerAlbumScreen.swift index 731527c89590..0c75bf1ca717 100644 --- a/WordPress/UITestsFoundation/Screens/Media/MediaPickerAlbumScreen.swift +++ b/WordPress/UITestsFoundation/Screens/Media/MediaPickerAlbumScreen.swift @@ -1,34 +1,32 @@ +import ScreenObject import XCTest -public class MediaPickerAlbumScreen: BaseScreen { - let mediaCollection: XCUIElement - let insertButton: XCUIElement - - public init() { - let app = XCUIApplication() - mediaCollection = app.collectionViews["MediaCollection"] - insertButton = app.buttons["SelectedActionButton"] +public class MediaPickerAlbumScreen: ScreenObject { + let mediaCollectionGetter: (XCUIApplication) -> XCUIElement = { + $0.collectionViews["MediaCollection"] + } - super.init(element: mediaCollection) + public init(app: XCUIApplication = XCUIApplication()) throws { + try super.init(expectedElementGetters: [mediaCollectionGetter], app: app) } public func selectImage(atIndex index: Int) { - let selectedImage = mediaCollection.cells.element(boundBy: index) + let selectedImage = mediaCollectionGetter(app).cells.element(boundBy: index) XCTAssertTrue(selectedImage.waitForExistence(timeout: 5), "Selected image did not load") selectedImage.tap() } func insertSelectedImage() { - insertButton.tap() + app.buttons["SelectedActionButton"].tap() } - public static func isLoaded() -> Bool { + public static func isLoaded(app: XCUIApplication = XCUIApplication()) -> Bool { // Check if the media picker is loaded as a component within the editor // and only return true if the media picker is a full screen - if XCUIApplication().navigationBars["Azctec Editor Navigation Bar"].exists { + if app.navigationBars["Azctec Editor Navigation Bar"].exists { return false } - return XCUIApplication().collectionViews["MediaCollection"].exists + return (try? MediaPickerAlbumScreen().isLoaded) ?? false } } diff --git a/WordPress/UITestsFoundation/Screens/MySiteScreen.swift b/WordPress/UITestsFoundation/Screens/MySiteScreen.swift index ca964cbee4ba..0a7a9d4d8107 100644 --- a/WordPress/UITestsFoundation/Screens/MySiteScreen.swift +++ b/WordPress/UITestsFoundation/Screens/MySiteScreen.swift @@ -90,14 +90,14 @@ public class MySiteScreen: BaseScreen { return try JetpackBackupScreen() } - public func gotoPostsScreen() -> PostsScreen { + public func gotoPostsScreen() throws -> PostsScreen { // A hack for iPad, because sometimes tapping "posts" doesn't load it the first time if XCUIDevice.isPad { mediaButton.tap() } postsButton.tap() - return PostsScreen() + return try PostsScreen() } public func gotoMediaScreen() -> MediaScreen { diff --git a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift index 92fde0d46714..5ac443196e25 100644 --- a/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift +++ b/WordPress/UITestsFoundation/Screens/NotificationsScreen.swift @@ -1,28 +1,28 @@ +import ScreenObject import XCTest -public class NotificationsScreen: BaseScreen { +public class NotificationsScreen: ScreenObject { - let replyButton: XCUIElement - - init() { - let navBar = XCUIApplication().tables["Notifications Table"] - replyButton = XCUIApplication().buttons["reply-button"] - - super.init(element: navBar) + init(app: XCUIApplication = XCUIApplication()) throws { + try super.init( + expectedElementGetters: [ { $0.tables["Notifications Table"] } ], + app: app + ) } public func openNotification(withText notificationText: String) -> NotificationsScreen { - XCUIApplication().staticTexts[notificationText].tap() + app.staticTexts[notificationText].tap() return self } @discardableResult public func replyToNotification() -> NotificationsScreen { + let replyButton = app.buttons["reply-button"] replyButton.tap() return self } public static func isLoaded() -> Bool { - return XCUIApplication().tables["Notifications Table"].exists + (try? NotificationsScreen().isLoaded) ?? false } } diff --git a/WordPress/UITestsFoundation/Screens/PostsScreen.swift b/WordPress/UITestsFoundation/Screens/PostsScreen.swift index de32a1346533..4d2eac5930c6 100644 --- a/WordPress/UITestsFoundation/Screens/PostsScreen.swift +++ b/WordPress/UITestsFoundation/Screens/PostsScreen.swift @@ -1,13 +1,7 @@ +import ScreenObject import XCTest -private struct ElementStringIDs { - static let draftsButton = "drafts" - static let publishedButton = "published" - - static let autosaveVersionsAlert = "autosave-options-alert" -} - -public class PostsScreen: BaseScreen { +public class PostsScreen: ScreenObject { public enum PostStatus { case published @@ -16,19 +10,18 @@ public class PostsScreen: BaseScreen { private var currentlyFilteredPostStatus: PostStatus = .published - init() { - super.init(element: XCUIApplication().tables["PostsTable"]) + init(app: XCUIApplication = XCUIApplication()) throws { + try super.init(expectedElementGetters: [ { $0.tables["PostsTable"] } ], app: app) showOnly(.published) } @discardableResult public func showOnly(_ status: PostStatus) -> PostsScreen { - switch status { - case .published: - XCUIApplication().buttons[ElementStringIDs.publishedButton].tap() - case .drafts: - XCUIApplication().buttons[ElementStringIDs.draftsButton].tap() + case .published: + app.buttons["published"].tap() + case .drafts: + app.buttons["drafts"].tap() } currentlyFilteredPostStatus = status @@ -44,7 +37,7 @@ public class PostsScreen: BaseScreen { let cell = expectedElement.cells[slug] XCTAssert(cell.waitForExistence(timeout: 5)) - scrollElementIntoView(element: cell, within: expectedElement) + cell.scrollIntoView(within: expectedElement) cell.tap() dismissAutosaveDialogIfNeeded() @@ -58,7 +51,7 @@ public class PostsScreen: BaseScreen { /// If there are two versions of a local post, the app will ask which version we want to use when editing. /// We always want to use the local version (which is currently the first option) private func dismissAutosaveDialogIfNeeded() { - let autosaveDialog = XCUIApplication().alerts[ElementStringIDs.autosaveVersionsAlert] + let autosaveDialog = app.alerts["autosave-options-alert"] if autosaveDialog.exists { autosaveDialog.buttons.firstMatch.tap() } diff --git a/WordPress/UITestsFoundation/Screens/ReaderScreen.swift b/WordPress/UITestsFoundation/Screens/ReaderScreen.swift index 3fffb038d0c0..fa833ce56726 100644 --- a/WordPress/UITestsFoundation/Screens/ReaderScreen.swift +++ b/WordPress/UITestsFoundation/Screens/ReaderScreen.swift @@ -1,22 +1,27 @@ +import ScreenObject import XCTest -private struct ElementStringIDs { - static let readerTable = "Reader" - static let discoverButton = "Discover" -} +public class ReaderScreen: ScreenObject { -public class ReaderScreen: BaseScreen { - let discoverButton: XCUIElement + private let discoverButtonGetter: (XCUIApplication) -> XCUIElement = { + $0.buttons["Discover"] + } - init() { - let readerTable = XCUIApplication().tables[ElementStringIDs.readerTable] - discoverButton = XCUIApplication().buttons[ElementStringIDs.discoverButton] + var discoverButton: XCUIElement { discoverButtonGetter(app) } - super.init(element: readerTable) + init(app: XCUIApplication = XCUIApplication()) throws { + try super.init( + expectedElementGetters: [ + // swiftlint:skip:next opening_brace + { $0.tables["Reader"] }, + discoverButtonGetter + ], + app: app + ) } public static func isLoaded() -> Bool { - return XCUIApplication().tables[ElementStringIDs.readerTable].exists + (try? ReaderScreen().isLoaded) ?? false } public func openDiscover() -> ReaderScreen { diff --git a/WordPress/UITestsFoundation/Screens/TabNavComponent.swift b/WordPress/UITestsFoundation/Screens/TabNavComponent.swift index 7f3551240072..da3357c867d3 100644 --- a/WordPress/UITestsFoundation/Screens/TabNavComponent.swift +++ b/WordPress/UITestsFoundation/Screens/TabNavComponent.swift @@ -63,14 +63,14 @@ public class TabNavComponent: ScreenObject { return BlockEditorScreen() } - public func gotoReaderScreen() -> ReaderScreen { + public func goToReaderScreen() throws -> ReaderScreen { readerTabButton.tap() - return ReaderScreen() + return try ReaderScreen() } - public func gotoNotificationsScreen() -> NotificationsScreen { + public func goToNotificationsScreen() throws -> NotificationsScreen { notificationsTabButton.tap() - return NotificationsScreen() + return try NotificationsScreen() } public static func isLoaded() -> Bool { diff --git a/WordPress/UITestsFoundation/XCUIElement+Scroll.swift b/WordPress/UITestsFoundation/XCUIElement+Scroll.swift new file mode 100644 index 000000000000..c5215ae81afa --- /dev/null +++ b/WordPress/UITestsFoundation/XCUIElement+Scroll.swift @@ -0,0 +1,23 @@ +import XCTest + +extension XCUIElement { + + /// Scroll an element into view within another element. + /// scrollView can be a UIScrollView, or anything that subclasses it like UITableView + /// + /// TODO: The implementation of this could use work: + /// - What happens if the element is above the current scroll view position? + /// - What happens if it's a really long scroll view? + public func scrollIntoView(within scrollView: XCUIElement, threshold: Int = 1000) { + var iteration = 0 + + while !isFullyVisibleOnScreen && iteration < threshold { + scrollView.scroll(byDeltaX: 0, deltaY: 100) + iteration += 1 + } + + if !isFullyVisibleOnScreen { + XCTFail("Unable to scroll element into view") + } + } +} diff --git a/WordPress/WordPress.xcodeproj/project.pbxproj b/WordPress/WordPress.xcodeproj/project.pbxproj index adf0222af9ed..c46a3a680c26 100644 --- a/WordPress/WordPress.xcodeproj/project.pbxproj +++ b/WordPress/WordPress.xcodeproj/project.pbxproj @@ -608,6 +608,7 @@ 3FB1929626C79EC6000F5AA3 /* Date+TimeStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FB1929426C79EC6000F5AA3 /* Date+TimeStrings.swift */; }; 3FB34ACB25672A90001A74A6 /* HomeWidgetTodayData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FB34ACA25672A90001A74A6 /* HomeWidgetTodayData.swift */; }; 3FB34ADA25672AA5001A74A6 /* HomeWidgetTodayData.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FB34ACA25672A90001A74A6 /* HomeWidgetTodayData.swift */; }; + 3FB5C2B327059AC8007D0ECE /* XCUIElement+Scroll.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FB5C2B227059AC8007D0ECE /* XCUIElement+Scroll.swift */; }; 3FBF21B7267AA17A0098335F /* BloggingRemindersAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FBF21B6267AA17A0098335F /* BloggingRemindersAnimator.swift */; }; 3FBF21B8267AA17A0098335F /* BloggingRemindersAnimator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3FBF21B6267AA17A0098335F /* BloggingRemindersAnimator.swift */; }; 3FC2C33D26C4CF0A00C6D98F /* XCUITestHelpers in Frameworks */ = {isa = PBXBuildFile; productRef = 3FC2C33C26C4CF0A00C6D98F /* XCUITestHelpers */; }; @@ -5216,6 +5217,7 @@ 3FB1928F26C6109F000F5AA3 /* TimeSelectionView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TimeSelectionView.swift; sourceTree = ""; }; 3FB1929426C79EC6000F5AA3 /* Date+TimeStrings.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Date+TimeStrings.swift"; sourceTree = ""; }; 3FB34ACA25672A90001A74A6 /* HomeWidgetTodayData.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeWidgetTodayData.swift; sourceTree = ""; }; + 3FB5C2B227059AC8007D0ECE /* XCUIElement+Scroll.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "XCUIElement+Scroll.swift"; sourceTree = ""; }; 3FBF21B6267AA17A0098335F /* BloggingRemindersAnimator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = BloggingRemindersAnimator.swift; sourceTree = ""; }; 3FC7F89D2612341900FD8728 /* UnifiedPrologueStatsContentView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnifiedPrologueStatsContentView.swift; sourceTree = ""; }; 3FC8D19A244F43B500495820 /* ReaderTabItemsStore.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReaderTabItemsStore.swift; sourceTree = ""; }; @@ -9465,6 +9467,7 @@ 3FE39A4326F8391D006E2B3A /* Screens */, 3FA640592670CCD40064401E /* UITestsFoundation.h */, 3F762E9426784B540088CD45 /* WireMock.swift */, + 3FB5C2B227059AC8007D0ECE /* XCUIElement+Scroll.swift */, 3F762E9A26784D2A0088CD45 /* XCUIElement+Utils.swift */, 3F762E9826784CC90088CD45 /* XCUIElementQuery+Utils.swift */, ); @@ -18527,6 +18530,7 @@ 3FA640642670CED80064401E /* BaseScreen.swift in Sources */, 3F2F856026FAF235000FCDA5 /* NotificationsScreen.swift in Sources */, 3F2F854026FAE9DC000FCDA5 /* BlockEditorScreen.swift in Sources */, + 3FB5C2B327059AC8007D0ECE /* XCUIElement+Scroll.swift in Sources */, 3F2F854726FAED51000FCDA5 /* MediaPickerAlbumListScreen.swift in Sources */, 3FE39A3626F8370D006E2B3A /* MySitesScreen.swift in Sources */, 3F762E9926784CC90088CD45 /* XCUIElementQuery+Utils.swift in Sources */, diff --git a/WordPress/WordPressScreenshotGeneration/WordPressScreenshotGeneration.swift b/WordPress/WordPressScreenshotGeneration/WordPressScreenshotGeneration.swift index 28dcb31c17b4..9ff0d40b0ef5 100644 --- a/WordPress/WordPressScreenshotGeneration/WordPressScreenshotGeneration.swift +++ b/WordPress/WordPressScreenshotGeneration/WordPressScreenshotGeneration.swift @@ -95,13 +95,13 @@ class WordPressScreenshotGeneration: XCTestCase { // Get Discover screenshot // Currently, the view includes the "You Might Like" section try TabNavComponent() - .gotoReaderScreen() + .goToReaderScreen() .openDiscover() .thenTakeScreenshot(2, named: "Discover") // Get Notifications screenshot let notificationList = try TabNavComponent() - .gotoNotificationsScreen() + .goToNotificationsScreen() .dismissNotificationAlertIfNeeded() if XCUIDevice.isPad { notificationList diff --git a/WordPress/WordPressUITests/Tests/MainNavigationTests.swift b/WordPress/WordPressUITests/Tests/MainNavigationTests.swift index 07a54cac8874..e9dbd8936be5 100644 --- a/WordPress/WordPressUITests/Tests/MainNavigationTests.swift +++ b/WordPress/WordPressUITests/Tests/MainNavigationTests.swift @@ -21,13 +21,18 @@ class MainNavigationTests: XCTestCase { func testTabBarNavigation() throws { XCTAssert(MySiteScreen.isLoaded(), "MySitesScreen screen isn't loaded.") - _ = mySiteScreen - .tabBar.gotoReaderScreen() + _ = try mySiteScreen + .tabBar.goToReaderScreen() XCTAssert(ReaderScreen.isLoaded(), "Reader screen isn't loaded.") + // We may get a notifications fancy alert when loading the reader for the first time + if let alert = try? FancyAlertComponent() { + alert.cancelAlert() + } + _ = try mySiteScreen - .tabBar.gotoNotificationsScreen() + .tabBar.goToNotificationsScreen() .dismissNotificationAlertIfNeeded() XCTContext.runActivity(named: "Confirm Notifications screen and main navigation bar are loaded.") { (activity) in