Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Commit 8000988

Browse files
authored
Bug 1487515 - XCUITest: Use internal web server (#4249)
* Bug 1487515 - XCUITest: Use internal web server * removing url from pre-loaded db test
1 parent 759377f commit 8000988

19 files changed

+3065
-85
lines changed

Diff for: Client.xcodeproj/xcshareddata/xcschemes/Fennec_Enterprise_SmokeXCUITests.xcscheme

-3
Original file line numberDiff line numberDiff line change
@@ -496,9 +496,6 @@
496496
<Test
497497
Identifier = "SaveLoginTest/testSaveLogin()">
498498
</Test>
499-
<Test
500-
Identifier = "SaveLoginTest/testSavedLoginSelectUnselect()">
501-
</Test>
502499
<Test
503500
Identifier = "SaveLoginTest/testSearchLogin()">
504501
</Test>

Diff for: Client.xcodeproj/xcshareddata/xcschemes/Fennec_Enterprise_XCUITests.xcscheme

+3-18
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,9 @@
214214
<Test
215215
Identifier = "BookmarkingTests/testBookmarksAwesomeBar()">
216216
</Test>
217+
<Test
218+
Identifier = "BrowsingPDFTests">
219+
</Test>
217220
<Test
218221
Identifier = "ClipBoardTests/testClipboardPasteAndGo()">
219222
</Test>
@@ -292,27 +295,9 @@
292295
<Test
293296
Identifier = "ReaderViewTest/testLoadReaderContent()">
294297
</Test>
295-
<Test
296-
Identifier = "SaveLoginTest/testDeleteLogin()">
297-
</Test>
298-
<Test
299-
Identifier = "SaveLoginTest/testDoNotSaveLogin()">
300-
</Test>
301-
<Test
302-
Identifier = "SaveLoginTest/testEditOneLoginEntry()">
303-
</Test>
304-
<Test
305-
Identifier = "SaveLoginTest/testSaveLogin()">
306-
</Test>
307-
<Test
308-
Identifier = "SaveLoginTest/testSavedLoginAutofilled()">
309-
</Test>
310298
<Test
311299
Identifier = "SaveLoginTest/testSavedLoginSelectUnselect()">
312300
</Test>
313-
<Test
314-
Identifier = "SaveLoginTest/testSearchLogin()">
315-
</Test>
316301
<Test
317302
Identifier = "SearchTests/testDismissPromptPresence()">
318303
</Test>

Diff for: XCUITests/ActivityStreamTest.swift

+4-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ class ActivityStreamTest: BaseTestCase {
109109

110110
func testTopSitesRemoveAllExceptDefaultClearPrivateData() {
111111
navigator.goto(BrowserTab)
112+
navigator.goto(BrowserTabMenu)
112113
navigator.goto(HomePanel_TopSites)
114+
waitforExistence(app.collectionViews.cells["mozilla"])
113115
XCTAssertTrue(app.collectionViews.cells["mozilla"].exists)
114116
// A new site has been added to the top sites
115117
checkNumberOfExpectedTopSites(numberOfExpectedTopSites: 6)
@@ -124,7 +126,8 @@ class ActivityStreamTest: BaseTestCase {
124126
func testTopSitesRemoveAllExceptPinnedClearPrivateData() {
125127
navigator.goto(BrowserTab)
126128
navigator.performAction(Action.PinToTopSitesPAM)
127-
navigator.goto(HomePanelsScreen)
129+
navigator.goto(BrowserTabMenu)
130+
navigator.goto(HomePanel_TopSites)
128131
waitforExistence(app.collectionViews.cells[newTopSite["topSiteLabel"]!])
129132
XCTAssertTrue(app.collectionViews.cells[newTopSite["topSiteLabel"]!].exists)
130133
checkNumberOfExpectedTopSites(numberOfExpectedTopSites: 6)
@@ -138,7 +141,6 @@ class ActivityStreamTest: BaseTestCase {
138141
}
139142

140143
func testTopSitesShiftAfterRemovingOne() {
141-
142144
// Check top site in first and second cell
143145
let topSiteFirstCell = app.collectionViews.cells.collectionViews.cells.element(boundBy: 0).label
144146
let topSiteSecondCell = app.collectionViews.cells.collectionViews.cells.element(boundBy: 1).label

Diff for: XCUITests/BrowsingPDFTests.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ let PDF_website = ["url": "http://www.pdf995.com/samples/pdf.pdf", "pdfValue": "
99
class BrowsingPDFTests: BaseTestCase {
1010
func testOpenPDFViewer() {
1111
navigator.openURL(PDF_website["url"]!)
12+
1213
waitUntilPageLoad()
1314
waitForValueContains(app.textFields["url"], value: PDF_website["pdfValue"]!)
14-
1515
// Swipe Up and Down
16-
let element = app/*@START_MENU_TOKEN@*/.webViews/*[[".otherElements[\"Web content\"].webViews",".otherElements[\"contentView\"].webViews",".webViews"],[[[-1,2],[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.children(matching: .other).element
16+
let element = app.children(matching: .other).element
1717
element.swipeUp()
1818
waitforExistence(app.staticTexts["2 of 5"])
1919

Diff for: XCUITests/FindInPageTest.swift

+29-12
Original file line numberDiff line numberDiff line change
@@ -13,24 +13,32 @@ class FindInPageTests: BaseTestCase {
1313

1414
waitforExistence(app.buttons["FindInPage.find_next"], timeout: 5)
1515
waitforExistence(app.buttons["FindInPage.find_previous"], timeout: 5)
16-
XCTAssertTrue(app.textFields[""].exists)
16+
XCTAssertTrue(app.textFields["FindInPage.searchField"].exists)
1717
}
1818

1919
func testFindInLargeDoc() {
20-
userState.url = "http://localhost:6571/find-in-page-test.html"
21-
openFindInPageFromMenu()
20+
navigator.openURL("http://localhost:6571/find-in-page-test.html")
21+
waitUntilPageLoad()
22+
// Workaround until FxSGraph is fixed to allow the previos way with goto
23+
navigator.nowAt(BrowserTab)
24+
25+
waitforExistence(app/*@START_MENU_TOKEN@*/.buttons["TabLocationView.pageOptionsButton"]/*[[".buttons[\"Page Options Menu\"]",".buttons[\"TabLocationView.pageOptionsButton\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/, timeout: 15)
26+
app/*@START_MENU_TOKEN@*/.buttons["TabLocationView.pageOptionsButton"]/*[[".buttons[\"Page Options Menu\"]",".buttons[\"TabLocationView.pageOptionsButton\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
27+
waitforExistence(app.tables["Context Menu"].cells["menu-FindInPage"], timeout: 10)
28+
app.tables["Context Menu"].cells["menu-FindInPage"].tap()
2229

2330
// Enter some text to start finding
24-
app.textFields[""].typeText("Book")
31+
app.textFields["FindInPage.searchField"].typeText("Book")
2532
waitforExistence(app.textFields["Book"], timeout: 15)
2633
XCTAssertEqual(app.staticTexts["FindInPage.matchCount"].label, "1/500+", "The book word count does match")
2734
}
2835

2936
func testFindFromMenu() {
37+
userState.url = path(forTestPage: "test-mozilla-book.html")
3038
openFindInPageFromMenu()
3139

3240
// Enter some text to start finding
33-
app.textFields[""].typeText("Book")
41+
app.textFields["FindInPage.searchField"].typeText("Book")
3442

3543
// Once there are matches, test previous/next buttons
3644
waitforExistence(app.staticTexts["1/6"])
@@ -61,21 +69,26 @@ class FindInPageTests: BaseTestCase {
6169
}
6270

6371
func testFindInPageTwoWordsSearch() {
72+
userState.url = path(forTestPage: "test-mozilla-book.html")
6473
openFindInPageFromMenu()
6574
// Enter some text to start finding
66-
app.textFields[""].typeText("The Book of")
75+
app.textFields["FindInPage.searchField"].typeText("The Book of")
6776

6877
// Once there are matches, test previous/next buttons
6978
waitforExistence(app.staticTexts["1/6"])
7079
XCTAssertTrue(app.staticTexts["1/6"].exists)
7180
}
7281

7382
func testFindInPageTwoWordsSearchLargeDoc() {
74-
userState.url = "http://localhost:6571/find-in-page-test.html"
75-
openFindInPageFromMenu()
76-
83+
navigator.openURL("http://localhost:6571/find-in-page-test.html")
84+
waitUntilPageLoad()
85+
// Workaround until FxSGraph is fixed to allow the previos way with goto
86+
navigator.nowAt(BrowserTab)
87+
waitforExistence(app/*@START_MENU_TOKEN@*/.buttons["TabLocationView.pageOptionsButton"]/*[[".buttons[\"Page Options Menu\"]",".buttons[\"TabLocationView.pageOptionsButton\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/, timeout: 15)
88+
app/*@START_MENU_TOKEN@*/.buttons["TabLocationView.pageOptionsButton"]/*[[".buttons[\"Page Options Menu\"]",".buttons[\"TabLocationView.pageOptionsButton\"]"],[[[-1,1],[-1,0]]],[0]]@END_MENU_TOKEN@*/.tap()
7789
// Enter some text to start finding
78-
app.textFields[""].typeText("The Book of")
90+
app.tables["Context Menu"].cells["menu-FindInPage"].tap()
91+
app.textFields["FindInPage.searchField"].typeText("The Book of")
7992
waitforExistence(app.textFields["The Book of"], timeout: 15)
8093
XCTAssertEqual(app.staticTexts["FindInPage.matchCount"].label, "1/500+", "The book word count does match")
8194
}
@@ -84,14 +97,15 @@ class FindInPageTests: BaseTestCase {
8497
userState.url = "lorem2.com"
8598
openFindInPageFromMenu()
8699
// Enter some text to start finding
87-
app.textFields[""].typeText("lorem")
100+
app.textFields["FindInPage.searchField"].typeText("lorem")
88101

89102
// There should be matches
90103
waitforExistence(app.staticTexts["1/5"])
91104
XCTAssertTrue(app.staticTexts["1/5"].exists)
92105
}
93106

94107
func testQueryWithNoMatches() {
108+
userState.url = path(forTestPage: "test-mozilla-book.html")
95109
openFindInPageFromMenu()
96110

97111
// Try to find text which does not match and check that there are not results
@@ -101,6 +115,7 @@ class FindInPageTests: BaseTestCase {
101115
}
102116

103117
func testBarDissapearsWhenReloading() {
118+
userState.url = path(forTestPage: "test-mozilla-book.html")
104119
openFindInPageFromMenu()
105120

106121
// Before reloading, it is necessary to hide the keyboard
@@ -113,6 +128,7 @@ class FindInPageTests: BaseTestCase {
113128
}
114129

115130
func testBarDissapearsWhenOpeningTabsTray() {
131+
userState.url = path(forTestPage: "test-mozilla-book.html")
116132
openFindInPageFromMenu()
117133

118134
// Dismiss keyboard
@@ -130,6 +146,7 @@ class FindInPageTests: BaseTestCase {
130146
}
131147

132148
func testFindFromSelection() {
149+
userState.url = path(forTestPage: "test-mozilla-book.html")
133150
navigator.goto(BrowserTab)
134151
let textToFind = "from"
135152

@@ -145,7 +162,7 @@ class FindInPageTests: BaseTestCase {
145162
if (app.menuItems["Find in Page"].exists) {
146163
app.menuItems["Find in Page"].tap()
147164
} else {
148-
app.menuItems["Show more items"].tap()
165+
app.menus.children(matching: .menuItem).element(boundBy: 3).tap()
149166
waitforExistence(app.menuItems["Find in Page"])
150167
app.menuItems["Find in Page"].tap()
151168
}

Diff for: XCUITests/FxScreenGraph.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -768,6 +768,7 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
768768
map.addScreenState(BrowserTab) { screenState in
769769
makeURLBarAvailable(screenState)
770770
screenState.tap(app.buttons["TabLocationView.pageOptionsButton"], to: PageOptionsMenu)
771+
screenState.tap(app.buttons["TabToolbar.menuButton"], to: BrowserTabMenu)
771772

772773
makeToolBarAvailable(screenState)
773774
let link = app.webViews.element(boundBy: 0).links.element(boundBy: 0)
@@ -821,7 +822,6 @@ func createScreenGraph(for test: XCTestCase, with app: XCUIApplication) -> MMScr
821822
map.addScreenState(PageOptionsMenu) {screenState in
822823
screenState.tap(app.tables["Context Menu"].cells["menu-FindInPage"], to: FindInPage)
823824
screenState.tap(app.tables["Context Menu"].cells["menu-Bookmark"], forAction: Action.BookmarkThreeDots, Action.Bookmark)
824-
screenState.tap(app.tables["Context Menu"].cells["action_remove"], forAction: Action.CloseTabFromPageOptions, Action.CloseTab, transitionTo: HomePanelsScreen, if: "tablet != true")
825825
screenState.tap(app.tables.cells["action_pin"], forAction: Action.PinToTopSitesPAM)
826826
screenState.tap(app.tables.cells["menu-Copy-Link"], forAction: Action.CopyAddressPAM)
827827
screenState.backAction = cancelBackAction

Diff for: XCUITests/HistoryTests.swift

+18-7
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class HistoryTests: BaseTestCase {
5050

5151
func testClearHistoryFromSettings() {
5252
// Browse to have an item in history list
53-
//navigator.goto(BrowserTabMenu)
5453
navigator.goto(HomePanel_History)
5554
waitforExistence(app.tables.cells["HistoryPanel.recentlyClosedCell"])
5655
XCTAssertTrue(app.tables.cells.staticTexts[webpage["label"]!].exists)
@@ -69,34 +68,41 @@ class HistoryTests: BaseTestCase {
6968
waitforNoExistence(app.tables["Recently Closed Tabs List"])
7069

7170
// Go to the default web site and check whether the option is enabled
71+
userState.url = path(forTestPage: "test-mozilla-book.html")
7272
navigator.goto(BrowserTab)
73-
waitUntilPageLoad()
7473
navigator.goto(BrowserTabMenu)
7574
navigator.goto(HistoryRecentlyClosed)
7675
waitforNoExistence(app.tables["Recently Closed Tabs List"])
7776

7877
// Now go back to default website close it and check whether the option is enabled
79-
navigator.goto(BrowserTab)
78+
navigator.openURL(path(forTestPage: "test-mozilla-book.html"))
79+
waitUntilPageLoad()
8080
navigator.goto(TabTray)
8181
navigator.performAction(Action.AcceptRemovingAllTabs)
82+
navigator.nowAt(NewTabScreen)
8283
navigator.goto(BrowserTabMenu)
8384
navigator.goto(HistoryRecentlyClosed)
8485

8586
// The Closed Tabs list should contain the info of the website just closed
86-
waitforExistence(app.tables["Recently Closed Tabs List"])
87+
waitforExistence(app.tables["Recently Closed Tabs List"], timeout: 3)
8788
XCTAssertTrue(app.tables.cells.staticTexts[closedWebPageLabel].exists)
8889

8990
// This option should be enabled on private mode too
9091
navigator.toggleOn(userState.isPrivate, withAction: Action.TogglePrivateMode)
92+
navigator.performAction(Action.OpenNewTabFromTabTray)
93+
navigator.nowAt(NewTabScreen)
94+
navigator.goto(BrowserTabMenu)
9195
navigator.goto(HistoryRecentlyClosed)
9296
waitforExistence(app.tables["Recently Closed Tabs List"])
9397
}
9498

9599
func testClearRecentlyClosedHistory() {
96100
// Open the default website
101+
userState.url = path(forTestPage: "test-mozilla-book.html")
97102
navigator.goto(BrowserTab)
98103
navigator.goto(TabTray)
99104
navigator.performAction(Action.AcceptRemovingAllTabs)
105+
navigator.nowAt(NewTabScreen)
100106
navigator.goto(BrowserTabMenu)
101107
navigator.goto(HistoryRecentlyClosed)
102108
// Once the website is visited and closed it will appear in Recently Closed Tabs list
@@ -113,10 +119,11 @@ class HistoryTests: BaseTestCase {
113119

114120
func testLongTapOptionsRecentlyClosedItem() {
115121
// Open the default website
122+
userState.url = path(forTestPage: "test-mozilla-book.html")
116123
navigator.goto(BrowserTab)
117124
navigator.goto(TabTray)
118125
navigator.performAction(Action.AcceptRemovingAllTabs)
119-
126+
navigator.nowAt(NewTabScreen)
120127
navigator.goto(BrowserTabMenu)
121128
navigator.goto(HistoryRecentlyClosed)
122129
waitforExistence(app.tables["Recently Closed Tabs List"])
@@ -129,10 +136,11 @@ class HistoryTests: BaseTestCase {
129136

130137
func testOpenInNewTabRecentlyClosedItem() {
131138
// Open the default website
139+
userState.url = path(forTestPage: "test-mozilla-book.html")
132140
navigator.goto(BrowserTab)
133141
navigator.goto(TabTray)
134142
navigator.performAction(Action.AcceptRemovingAllTabs)
135-
143+
navigator.nowAt(NewTabScreen)
136144
navigator.goto(HistoryRecentlyClosed)
137145
waitforExistence(app.tables["Recently Closed Tabs List"])
138146
XCTAssertTrue(app.tables.cells.staticTexts[closedWebPageLabel].exists)
@@ -148,9 +156,11 @@ class HistoryTests: BaseTestCase {
148156

149157
func testOpenInNewPrivateTabRecentlyClosedItem() {
150158
// Open the default website
159+
userState.url = path(forTestPage: "test-mozilla-book.html")
151160
navigator.goto(BrowserTab)
152161
navigator.goto(TabTray)
153162
navigator.performAction(Action.AcceptRemovingAllTabs)
163+
navigator.nowAt(NewTabScreen)
154164
navigator.goto(HistoryRecentlyClosed)
155165
waitforExistence(app.tables["Recently Closed Tabs List"])
156166
XCTAssertTrue(app.tables.cells.staticTexts[closedWebPageLabel].exists)
@@ -168,9 +178,10 @@ class HistoryTests: BaseTestCase {
168178
func testPrivateClosedSiteDoesNotAppearOnRecentlyClosed() {
169179
navigator.toggleOn(userState.isPrivate, withAction: Action.TogglePrivateMode)
170180
// Open the default website
181+
userState.url = path(forTestPage: "test-mozilla-book.html")
171182
navigator.goto(BrowserTab)
172183
// It is necessary to open two sites so that when one is closed private mode is not closed
173-
navigator.openNewURL(urlString: "mozilla.org")
184+
navigator.openNewURL(urlString: path(forTestPage: "test-mozilla-org.html"))
174185
waitUntilPageLoad()
175186
navigator.goto(TabTray)
176187
waitforExistence(app.collectionViews.cells[webpage["label"]!])

Diff for: XCUITests/HomePageSettingsUITest.swift

+4-1
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,13 @@ class HomePageSettingsUITests: BaseTestCase {
4444
navigator.goto(SettingsScreen)
4545
// Check that it is not saved
4646
navigator.goto(HomePageSettings)
47+
waitforExistence(app.textFields["HomePageSettingTextField"])
4748
let valueAfter = app.textFields["HomePageSettingTextField"].value
4849
XCTAssertEqual("Enter a webpage", valueAfter as! String)
4950

5051
// There is no option to go to Home, instead the website open has the option to be set as HomePageSettings
51-
navigator.openURL(websiteUrl1)
52+
navigator.openURL(path(forTestPage: "test-mozilla-org.html"))
53+
waitUntilPageLoad()
5254
navigator.goto(BrowserTabMenu)
5355
let homePageMenuItem = app.tables["Context Menu"].cells["Open Homepage"]
5456
XCTAssertFalse(homePageMenuItem.exists)
@@ -83,6 +85,7 @@ class HomePageSettingsUITests: BaseTestCase {
8385
app.textFields["address"].press(forDuration: 5)
8486
app.menuItems["Select All"].tap()
8587
app.menuItems["Copy"].tap()
88+
waitforExistence(app.buttons["goBack"])
8689
app.buttons["goBack"].tap()
8790

8891
// Go to HomePage settings and check that it is not possible to copy it into the set webpage field

Diff for: XCUITests/NewTabSettings.swift

+1-2
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,8 @@ class NewTabSettingsTest: BaseTestCase {
6060
waitforExistence(app.otherElements.images["emptyBookmarks"])
6161

6262
// Add one bookmark and check the new tab screen
63-
navigator.openURL("mozilla.org/en-US/book")
63+
navigator.openURL(path(forTestPage: "test-mozilla-book.html"))
6464
waitUntilPageLoad()
65-
navigator.nowAt(BrowserTab)
6665
navigator.performAction(Action.Bookmark)
6766
navigator.goto(NewTabScreen)
6867
waitforExistence(app.tables["Bookmarks List"].cells.staticTexts["The Book of Mozilla"])

Diff for: XCUITests/PocketTests.swift

+3
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,11 @@ class PocketTest: BaseTestCase {
3737
func testTapOnMore() {
3838
// Tap on More should show Pocket website
3939
navigator.goto(NewTabScreen)
40+
waitforExistence(app.buttons["More"], timeout: 5)
4041
app.buttons["More"].tap()
4142
waitUntilPageLoad()
43+
navigator.nowAt(BrowserTab)
44+
waitforExistence(app.buttons["Reader View"], timeout: 10)
4245
waitForValueContains(app.textFields["url"], value: "getpocket")
4346
}
4447
}

Diff for: XCUITests/PrivateBrowsingTest.swift

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class PrivateBrowsingTest: BaseTestCase {
120120
// See scenario described in bug 1434545 for more info about this scenario
121121
enableClosePrivateBrowsingOptionWhenLeaving()
122122
navigator.openURL(urlExample)
123+
waitUntilPageLoad()
123124
app.webViews.links.staticTexts["More information..."].press(forDuration: 3)
124125
app.buttons["Open in New Private Tab"].tap()
125126
waitUntilPageLoad()

0 commit comments

Comments
 (0)