Skip to content

Commit

Permalink
Fixes MTE-2812 - auto tests for toolbar changes
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosb01 committed Nov 26, 2024
1 parent ad0a142 commit 17a0104
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ class FirefoxSuggestTest: BaseTestCase {
// https://mozilla.testrail.io/index.php?/cases/view/2360075
func testFirefoxSuggestExists() {
navigator.openURL("www.example.com")
waitUntilPageLoad()
navigator.createNewTab()
navigator.goto(URLBarOpen)
urlBarAddress.typeText("ex")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
screenState.tap(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton], to: TabTray)
} else {
screenState.gesture(to: TabTray) {
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].tap()
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].waitAndTap()
}
}
makeURLBarAvailable(screenState)
Expand Down Expand Up @@ -460,7 +460,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
screenState.tap(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton], to: TabTray)
} else {
screenState.gesture(to: TabTray) {
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].tap()
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].waitAndTap()
}
}

Expand Down Expand Up @@ -942,7 +942,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
screenState.tap(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton], to: TabTray)
} else {
screenState.gesture(to: TabTray) {
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].tap()
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].waitAndTap()
}
}
}
Expand Down Expand Up @@ -991,7 +991,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
screenState.tap(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton], to: TabTray)
} else {
screenState.gesture(to: TabTray) {
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].tap()
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].waitAndTap()
}
}

Expand Down Expand Up @@ -1241,8 +1241,7 @@ extension MMNavigator where T == FxUserState {
func createNewTab() {
let app = XCUIApplication()
self.goto(TabTray)
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.TabTray.newTabButton], timeout: TIMEOUT)
app.buttons[AccessibilityIdentifiers.TabTray.newTabButton].tap()
app.buttons[AccessibilityIdentifiers.TabTray.newTabButton].waitAndTap()
self.nowAt(NewTabScreen)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ class HomeButtonTests: BaseTestCase {
// Switch to Homepage by taping the home button
app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton].waitAndTap()

validateHomePageAndKeyboardNotRaisedUp()
validateHomePageAndKeyboardRaisedUp()
}

// https://mozilla.testrail.io/index.php?/cases/view/2306881
func testAppLaunchKeyboardNotRaisedUp() {
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton])
validateHomePageAndKeyboardNotRaisedUp()
validateHomePageAndKeyboardRaisedUp()
}

private func validateHomePageAndKeyboardNotRaisedUp() {
private func validateHomePageAndKeyboardRaisedUp() {
// The home page is loaded. The keyboard is not raised up
navigator.nowAt(NewTabScreen)
waitForTabsButton()
XCTAssertFalse(app.keyboards.element.isVisible(), "The keyboard is shown")
XCTAssertTrue(app.keyboards.element.isVisible(), "The keyboard is not shown")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -266,10 +266,8 @@ class HomePageSettingsUITests: BaseTestCase {
bookmarkPages()
addContentToReaderView()
if iPad() {
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].tap()
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.TabTray.newTabButton])
app.buttons[AccessibilityIdentifiers.TabTray.newTabButton].tap()
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].waitAndTap()
app.buttons[AccessibilityIdentifiers.TabTray.newTabButton].waitAndTap()
} else {
navigator.performAction(Action.GoToHomePage)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ class NavigationTest: BaseTestCase {
if iPad() {
if let urlTextField = app.textFields[AccessibilityIdentifiers.Browser.AddressToolbar.searchTextField].value
as? String,
urlTextField == "ultimateqa.com/dummy-automation-websites" {
urlTextField == "ultimateqa.com" {
app.links["SauceDemo.com"].firstMatch.tap(force: true)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ class ReadingListTests: BaseTestCase {
// Add item to reading list and check that it appears
addContentToReaderView()
navigator.goto(BrowserTabMenu)
if iPad() {
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].tapOnApp()
}
navigator.goto(LibraryPanel_ReadingList)

// Check that there is one item
Expand All @@ -73,9 +70,6 @@ class ReadingListTests: BaseTestCase {
// Add item to reading list and check that it appears
addContentToReaderView()
navigator.goto(BrowserTabMenu)
if iPad() {
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].tapOnApp()
}
navigator.goto(LibraryPanel_ReadingList)

// Check that there is one item
Expand Down Expand Up @@ -119,9 +113,6 @@ class ReadingListTests: BaseTestCase {

// Go to reader list view to check that there is not any item there
navigator.goto(BrowserTabMenu)
if iPad() {
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].tapOnApp()
}
navigator.goto(LibraryPanel_ReadingList)
checkReadingListNumberOfItems(items: 0)
}
Expand All @@ -130,9 +121,6 @@ class ReadingListTests: BaseTestCase {
func testMarkAsReadAndUnreadFromReadingList() throws {
addContentToReaderView()
navigator.goto(BrowserTabMenu)
if iPad() {
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].tapOnApp()
}
navigator.goto(LibraryPanel_ReadingList)

mozWaitForElementToExist(app.tables["ReadingTable"])
Expand All @@ -152,9 +140,6 @@ class ReadingListTests: BaseTestCase {
func testRemoveFromReadingList() {
addContentToReaderView()
navigator.goto(BrowserTabMenu)
if iPad() {
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].tapOnApp()
}
navigator.goto(LibraryPanel_ReadingList)

let savedToReadingList = app.tables["ReadingTable"].cells.staticTexts["The Book of Mozilla"]
Expand Down Expand Up @@ -194,9 +179,6 @@ class ReadingListTests: BaseTestCase {

// Add item to Reading List
addContentToReaderView()
if iPad() {
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].tapOnApp()
}
navigator.goto(LibraryPanel_ReadingList)

// Long tap on the item just saved
Expand All @@ -219,9 +201,6 @@ class ReadingListTests: BaseTestCase {
func testRemoveSavedForReadingLongPress() {
// Add item to Reading List
addContentToReaderView()
if iPad() {
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].tapOnApp()
}
navigator.goto(LibraryPanel_ReadingList)

// Long tap on the item just saved and choose remove
Expand Down Expand Up @@ -255,9 +234,6 @@ class ReadingListTests: BaseTestCase {
// Add item to reading list and check that it appears
addContentToReaderView()
navigator.goto(BrowserTabMenu)
if iPad() {
app.buttons[AccessibilityIdentifiers.Toolbar.settingsMenuButton].tapOnApp()
}
navigator.goto(LibraryPanel_ReadingList)
let savedToReadingList = app.tables["ReadingTable"].cells.staticTexts["The Book of Mozilla"]
mozWaitForElementToExist(savedToReadingList)
Expand Down
16 changes: 4 additions & 12 deletions firefox-ios/firefox-ios-tests/Tests/XCUITests/ToolbarTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -156,22 +156,14 @@ class ToolbarTests: BaseTestCase {
}

private func validateAddNewTabButtonOnToolbar(isPrivate: Bool) {
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
restartInBackground()
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton])
restartInBackground()
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
// Swipe up to close the app does not work on iOS 15.
if #available(iOS 16, *) {
closeFromAppSwitcherAndRelaunch()
let addNewTabButton = app.buttons[AccessibilityIdentifiers.Toolbar.addNewTabButton]
mozWaitForElementToExist(addNewTabButton)
addNewTabButton.tapOnApp()
if !app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].exists {
addNewTabButton.tap()
}
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].waitAndTap()
app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].waitAndTap()
app.buttons[AccessibilityIdentifiers.TabTray.newTabButton].waitAndTap()
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton])
XCTAssertEqual(app.buttons[AccessibilityIdentifiers.Toolbar.tabsButton].value as? String, "2")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,7 @@ class TrackingProtectionTests: BaseTestCase {
waitForElementsToExist(
[
app.staticTexts["mozilla.org"],
// Need to determine what message should be displayed inside TP screen
// app.staticTexts["Secure connection"]
app.staticTexts["Connection not secure"]
app.staticTexts["Secure connection"]
]
)
XCTAssertEqual(
Expand Down

0 comments on commit 17a0104

Please sign in to comment.