Skip to content

Commit

Permalink
Refactored MTE-3645 - url strings with single path identifier (#22367)
Browse files Browse the repository at this point in the history
  • Loading branch information
dragosb01 authored Oct 3, 2024
1 parent 13e7847 commit 7c62531
Show file tree
Hide file tree
Showing 34 changed files with 177 additions and 150 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ class ActivityStreamTest: BaseTestCase {
waitForExistence(topSitesCells.staticTexts[newTopSiteiOS15["bookmarkLabel"]!], timeout: TIMEOUT_LONG)
}

waitForExistence(app.buttons["urlBar-cancel"])
waitForExistence(app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton])
navigator.performAction(Action.CloseURLBarOpen)
navigator.nowAt(NewTabScreen)
navigator.goto(SettingsScreen)
Expand Down Expand Up @@ -206,7 +206,7 @@ class ActivityStreamTest: BaseTestCase {

// The website is open
mozWaitForElementToNotExist(TopSiteCellgroup)
waitForValueContains(app.textFields["url"], value: "wikipedia.org")
waitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "wikipedia.org")
}

// Smoketest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ let testBasicHTTPAuthURL = "https://jigsaw.w3.org/HTTP/Basic/"
class AuthenticationTest: BaseTestCase {
// https://mozilla.testrail.io/index.php?/cases/view/2360560
func testBasicHTTPAuthenticationPromptVisible() {
mozWaitForElementToExist(app.textFields["url"])
mozWaitForElementToExist(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url])
navigator.nowAt(NewTabScreen)
navigator.openURL(testBasicHTTPAuthURL)
mozWaitForElementToExist(app.staticTexts["Authentication required"], timeout: 100)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ class BaseTestCase: XCTestCase {
func loadWebPage(_ url: String, waitForLoadToFinish: Bool = true, file: String = #file, line: UInt = #line) {
let app = XCUIApplication()
UIPasteboard.general.string = url
app.textFields["url"].press(forDuration: 2.0)
app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].press(forDuration: 2.0)
app.tables["Context Menu"].cells[AccessibilityIdentifiers.Photon.pasteAndGoAction].firstMatch.tap()

if waitForLoadToFinish {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class BookmarksTests: BaseTestCase {
// Smoketest
func testBookmarksAwesomeBar() {
XCTExpectFailure("The app was not launched", strict: false) {
mozWaitForElementToExist(app.textFields["url"], timeout: TIMEOUT_LONG)
mozWaitForElementToExist(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], timeout: TIMEOUT_LONG)
}
typeOnSearchBar(text: "www.google")
mozWaitForElementToExist(app.tables["SiteTable"])
Expand Down Expand Up @@ -165,7 +165,7 @@ class BookmarksTests: BaseTestCase {
addNewBookmark()
// Verify that clicking on bookmark opens the website
app.tables["Bookmarks List"].cells.element(boundBy: 1).tap()
mozWaitForElementToExist(app.textFields["url"])
mozWaitForElementToExist(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url])
}

// https://mozilla.testrail.io/index.php?/cases/view/2306914
Expand Down Expand Up @@ -269,8 +269,8 @@ class BookmarksTests: BaseTestCase {
}

private func typeOnSearchBar(text: String) {
mozWaitForElementToExist(app.textFields["url"])
app.textFields["url"].tap()
mozWaitForElementToExist(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url])
app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].tap()
app.textFields["address"].typeText(text)
}

Expand All @@ -279,7 +279,7 @@ class BookmarksTests: BaseTestCase {
func testBookmarkLibraryAddDeleteBookmark() {
// Verify that there are only 1 cell (desktop bookmark folder)
XCTExpectFailure("The app was not launched", strict: false) {
mozWaitForElementToExist(app.textFields["url"], timeout: TIMEOUT_LONG)
mozWaitForElementToExist(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], timeout: TIMEOUT_LONG)
}
navigator.nowAt(NewTabScreen)
waitForTabsButton()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ let PDF_website = [
"bookmarkLabel": "https://storage.googleapis.com/mobile_test_assets/public/pdf-test.pdf",
"longUrlValue": "http://www.education.gov.yk.ca/"
]

class BrowsingPDFTests: BaseTestCase {
let url = XCUIApplication().textFields[AccessibilityIdentifiers.Browser.UrlBar.url]

// https://mozilla.testrail.io/index.php?/cases/view/2307116
func testOpenPDFViewer() {
navigator.openURL(PDF_website["url"]!)
waitUntilPageLoad()
mozWaitForValueContains(app.textFields["url"], value: PDF_website["pdfValue"]!)
mozWaitForValueContains(url, value: PDF_website["pdfValue"]!)
// Swipe Up and Down
app.swipeUp()
mozWaitForElementToExist(app.staticTexts["1 of 1"])
Expand All @@ -34,12 +37,12 @@ class BrowsingPDFTests: BaseTestCase {
// Click on a link on the pdf and check that the website is shown
app.links.element(boundBy: 0).tapOnApp()
waitUntilPageLoad()
mozWaitForValueContains(app.textFields["url"], value: PDF_website["urlValue"]!)
mozWaitForValueContains(url, value: PDF_website["urlValue"]!)
mozWaitForElementToExist(app.staticTexts["Education and schools"])

// Go back to pdf view
app.buttons[AccessibilityIdentifiers.Toolbar.backButton].tap()
mozWaitForValueContains(app.textFields["url"], value: PDF_website["pdfValue"]!)
mozWaitForValueContains(url, value: PDF_website["pdfValue"]!)
}

// https://mozilla.testrail.io/index.php?/cases/view/2307118
Expand Down Expand Up @@ -97,7 +100,7 @@ class BrowsingPDFTests: BaseTestCase {
.element(boundBy: 0)
pdfTopSite.tap()
waitUntilPageLoad()
mozWaitForValueContains(app.textFields["url"], value: PDF_website["pdfValue"]!)
mozWaitForValueContains(url, value: PDF_website["pdfValue"]!)

// Remove pdf pinned site
navigator.performAction(Action.OpenNewTabFromTabTray)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class ClipBoardTests: BaseTestCase {

// Check for test url in the browser
func checkUrl() {
let urlTextField = app.textFields["url"]
let urlTextField = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
mozWaitForValueContains(urlTextField, value: "www.example")
}

Expand Down Expand Up @@ -38,7 +38,7 @@ class ClipBoardTests: BaseTestCase {
allowBtn.tap()
}

var value = app.textFields["url"].value as! String
var value = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].value as! String
if value.hasPrefix("http") == false {
value = "http://\(value)"
}
Expand Down Expand Up @@ -103,13 +103,13 @@ class ClipBoardTests: BaseTestCase {
// mozWaitForElementToNotExist(app.staticTexts["XCUITests-Runner pasted from Fennec"])
// navigator.createNewTab()
// mozWaitForElementToNotExist(app.staticTexts["XCUITests-Runner pasted from Fennec"])
// app.textFields["url"].press(forDuration: 3)
// app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].press(forDuration: 3)
// mozWaitForElementToExist(app.tables["Context Menu"])
// mozWaitForElementToExist(
// app.tables["Context Menu"].otherElements[AccessibilityIdentifiers.Photon.pasteAndGoAction]
// )
// app.tables["Context Menu"].otherElements[AccessibilityIdentifiers.Photon.pasteAndGoAction].tap()
// mozWaitForElementToExist(app.textFields["url"])
// mozWaitForValueContains(app.textFields["url"], value: "www.example.com")
// mozWaitForElementToExist(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url])
// mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "www.example.com")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ class DownloadsTests: BaseTestCase {

// Remove private data once the switch to remove downloaded files is enabled
navigator.goto(NewTabScreen)
mozWaitForElementToExist(app.buttons["urlBar-cancel"])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton])
navigator.performAction(Action.CloseURLBarOpen)
navigator.nowAt(NewTabScreen)
navigator.goto(ClearPrivateDataSettings)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,9 @@ class DragAndDropTests: BaseTestCase {
)
checkTabsOrder(dragAndDropTab: true, firstTab: secondWebsite.tabName, secondTab: firstWebsite.tabName)
if !iPad() {
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
XCTAssert(
secondWebsite.url.contains(app.textFields["url"].value! as! String),
"The tab has not been dropped correctly"
secondWebsite.url.contains(url.value! as! String), "The tab has not been dropped correctly"
) } else {
XCTAssertEqual(app.otherElements["Tabs Tray"].cells.element(boundBy: 0).label, secondWebsite.tabName)
}
Expand All @@ -135,9 +135,9 @@ class DragAndDropTests: BaseTestCase {
checkTabsOrder(dragAndDropTab: true, firstTab: secondWebsite.tabName, secondTab: homeTabName)
// Check that focus is kept on last website open
if !iPad() {
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
XCTAssert(
secondWebsite.url.contains(app.textFields["url"].value! as! String),
"The tab has not been dropped correctly"
secondWebsite.url.contains(url.value! as! String), "The tab has not been dropped correctly"
) } else {
XCTAssertEqual(app.otherElements["Tabs Tray"].cells.element(boundBy: 0).label, secondWebsite.tabName)
}
Expand Down Expand Up @@ -266,7 +266,7 @@ class DragAndDropTestIpad: IpadOnlyTestCase {
checkTabsOrder(dragAndDropTab: true, firstTab: secondWebsite.tabName, secondTab: firstWebsite.tabName)
// Check that focus is kept on last website open
XCTAssert(
secondWebsite.url.contains(app.textFields["url"].value! as! String),
secondWebsite.url.contains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].value! as! String),
"The tab has not been dropped correctly"
)
}
Expand Down Expand Up @@ -302,7 +302,7 @@ class DragAndDropTestIpad: IpadOnlyTestCase {
mozWaitForElementToExist(searchField)

// DragAndDrop the url for only one second so that the TP menu is not shown and the search box is not covered
app.textFields["url"].press(forDuration: 1, thenDragTo: searchField)
app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].press(forDuration: 1, thenDragTo: searchField)

// Verify that the text in the search field is the same as the text in the url text field
searchField.tap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ final class ExperimentIntegrationTests: BaseTestCase {

wait(forElement: surveyLink.element, timeout: TIMEOUT_LONG)
surveyLink.element.tap()
mozWaitForValueContains(app.textFields["url"], value: "survey")
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "survey")
}

func testMessageNoThanksNavigatesCorrectly() throws {
Expand Down Expand Up @@ -99,7 +99,7 @@ final class ExperimentIntegrationTests: BaseTestCase {

wait(forElement: surveyLink.element, timeout: TIMEOUT_LONG)
surveyLink.element.tap()
mozWaitForValueContains(app.textFields["url"], value: "survey")
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "survey")
}

func testHomeScreenMessageNavigatesCorrectly() throws {
Expand All @@ -109,7 +109,7 @@ final class ExperimentIntegrationTests: BaseTestCase {

wait(forElement: surveyLink.element, timeout: TIMEOUT_LONG)
surveyLink.element.tap()
mozWaitForValueContains(app.textFields["url"], value: "survey")
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "survey")
}

func testHomeScreenMessageDismissesCorrectly() throws {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ class FakespotTests: BaseTestCase {
app.buttons[shoppingIdentifier.turnOffButton].tap()
// The 'Review quality check' bottom sheet/sidebar closes
mozWaitForElementToNotExist(app.staticTexts[AccessibilityIdentifiers.Shopping.sheetHeaderTitle])
mozWaitForValueContains(app.textFields["url"], value: "www.amazon.com")
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "www.amazon.com")
// In a new tab, navigate to a product detail page on amazon.com
navigator.performAction(Action.OpenNewTabFromTabTray)
reachReviewChecker()
Expand Down Expand Up @@ -270,7 +270,7 @@ class FakespotTests: BaseTestCase {

private func validateMozillaSupportWebpage(_ webpageTitle: String, _ url: String) {
mozWaitForElementToExist(app.staticTexts[webpageTitle])
mozWaitForValueContains(app.textFields["url"], value: url)
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: url)
let numTab = app.buttons["Show Tabs"].value as? String
XCTAssertEqual(numTab, "2")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ class FindInPageTests: BaseTestCase {
openFindInPageFromMenu(openSite: userState.url!)

// Before reloading, it is necessary to hide the keyboard
app.textFields["url"].tap()
app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].tap()
app.textFields["address"].typeText("\n")

// Once the page is reloaded the search bar should not appear
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
screenState.noop(to: HomePanel_TopSites)

screenState.backAction = {
app.buttons["urlBar-cancel"].tap()
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].tap()
}
screenState.dismissOnUse = true
}
Expand Down Expand Up @@ -464,7 +464,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
}

screenState.gesture(forAction: Action.CloseURLBarOpen, transitionTo: HomePanelsScreen) {_ in
app.buttons["urlBar-cancel"].tap()
app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton].tap()
}
}

Expand Down Expand Up @@ -932,9 +932,9 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
}

func makeURLBarAvailable(_ screenState: MMScreenStateNode<FxUserState>) {
screenState.tap(app.textFields["url"], to: URLBarOpen)
screenState.tap(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], to: URLBarOpen)
screenState.gesture(to: URLBarLongPressMenu) {
app.textFields["url"].press(forDuration: 1.0)
app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url].press(forDuration: 1.0)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -371,7 +371,8 @@ class HistoryTests: BaseTestCase {
urlBarForwardButton.press(forDuration: 1)
mozWaitForElementToExist(app.tables.staticTexts["The Book of Mozilla"])
app.tables.staticTexts["The Book of Mozilla"].tap()
mozWaitForValueContains(app.textFields["url"], value: "test-fixture/test-mozilla-book.html")
let url = app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url]
mozWaitForValueContains(url, value: "test-fixture/test-mozilla-book.html")
}

// Private function created to select desired option from the "Clear Recent History" list
Expand All @@ -387,7 +388,8 @@ class HistoryTests: BaseTestCase {
// Workaround as the item does not appear if there is only that tab open
navigator.goto(TabTray)
navigator.performAction(Action.OpenNewTabFromTabTray)
mozWaitForElementToExist(app.buttons["urlBar-cancel"], timeout: TIMEOUT_LONG)
let cancelButton = app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton]
mozWaitForElementToExist(cancelButton, timeout: TIMEOUT_LONG)
navigator.performAction(Action.CloseURLBarOpen)
waitForTabsButton()
navigator.nowAt(NewTabScreen)
Expand Down Expand Up @@ -421,7 +423,7 @@ class HistoryTests: BaseTestCase {
}

private func closeKeyboard() {
mozWaitForElementToExist(app.buttons["urlBar-cancel"])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton])
navigator.performAction(Action.CloseURLBarOpen)
navigator.nowAt(NewTabScreen)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class HomePageSettingsUITests: BaseTestCase {
mozWaitForElementToExist(homePageMenuItem)
homePageMenuItem.tap()
waitUntilPageLoad()
mozWaitForValueContains(app.textFields["url"], value: "example")
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "example")
}

// https://mozilla.testrail.io/index.php?/cases/view/2339258
Expand Down Expand Up @@ -134,7 +134,7 @@ class HomePageSettingsUITests: BaseTestCase {
waitUntilPageLoad()
navigator.nowAt(BrowserTab)
navigator.performAction(Action.GoToHomePage)
mozWaitForElementToExist(app.textFields["url"])
mozWaitForElementToExist(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url])

// Now after setting History, make sure FF home is set
navigator.goto(SettingsScreen)
Expand All @@ -161,8 +161,8 @@ class HomePageSettingsUITests: BaseTestCase {

// Workaround needed after Xcode 11.3 update Issue 5937
// Lets check only that website is open
mozWaitForElementToExist(app.textFields["url"])
mozWaitForValueContains(app.textFields["url"], value: "mozilla")
mozWaitForElementToExist(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url])
mozWaitForValueContains(app.textFields[AccessibilityIdentifiers.Browser.UrlBar.url], value: "mozilla")
}

// https://mozilla.testrail.io/index.php?/cases/view/2339489
Expand Down Expand Up @@ -222,7 +222,7 @@ class HomePageSettingsUITests: BaseTestCase {
navigator.performAction(Action.OpenNewTabFromTabTray)
navigator.nowAt(NewTabScreen)
if !iPad() {
mozWaitForElementToExist(app.buttons["urlBar-cancel"])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton])
navigator.performAction(Action.CloseURLBarOpen)
}
mozWaitForElementToExist(
Expand Down Expand Up @@ -268,14 +268,14 @@ class HomePageSettingsUITests: BaseTestCase {
mozWaitForElementToNotExist(
app.scrollViews.cells[AccessibilityIdentifiers.FirefoxHomepage.MoreButtons.bookmarks]
)
mozWaitForElementToExist(app.buttons["urlBar-cancel"])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton])
navigator.performAction(Action.CloseURLBarOpen)
navigator.nowAt(NewTabScreen)
navigator.performAction(Action.ToggleRecentlySaved)
navigator.nowAt(HomeSettings)
navigator.performAction(Action.OpenNewTabFromTabTray)
if !iPad() {
mozWaitForElementToExist(app.buttons["urlBar-cancel"])
mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton])
navigator.performAction(Action.CloseURLBarOpen)
}
checkBookmarks()
Expand Down Expand Up @@ -325,7 +325,7 @@ class HomePageSettingsUITests: BaseTestCase {
// .staticTexts[urlMozillaLabel].exists
// )
// if !iPad() {
// mozWaitForElementToExist(app.buttons["urlBar-cancel"], timeout: 3)
// mozWaitForElementToExist(app.buttons[AccessibilityIdentifiers.Browser.UrlBar.cancelButton], timeout: 3)
// navigator.performAction(Action.CloseURLBarOpen)
// }
// navigator.nowAt(NewTabScreen)
Expand Down
Loading

0 comments on commit 7c62531

Please sign in to comment.