Skip to content

Commit

Permalink
FindInPage XCUITests (#2520)
Browse files Browse the repository at this point in the history
Failing tests due to a known bug commented and disabling LivePushClientTests which make the build timeout in bb

Comment test that fails due to existing bug
  • Loading branch information
isabelrios committed Mar 29, 2017
1 parent a18df19 commit acdd7a2
Show file tree
Hide file tree
Showing 5 changed files with 122 additions and 128 deletions.
8 changes: 4 additions & 4 deletions Client.xcodeproj/project.pbxproj
Expand Up @@ -139,6 +139,7 @@
28FDFF0C1C1F725800840F86 /* SeparatorTableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28FDFF0B1C1F725800840F86 /* SeparatorTableCell.swift */; };
2C2A5EF41E68469500F02659 /* PrivateBrowsingTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C2A5EF31E68469500F02659 /* PrivateBrowsingTest.swift */; };
2C3406C81E719F00000FD889 /* SettingsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C3406C71E719F00000FD889 /* SettingsTest.swift */; };
2C8C07771E7800EA00DC1237 /* FindInPageTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C8C07761E7800EA00DC1237 /* FindInPageTest.swift */; };
2C97EC711E72C80E0092EC18 /* TopTabsTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2C97EC701E72C80E0092EC18 /* TopTabsTest.swift */; };
2CA16FDE1E5F089100332277 /* SearchTest.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2CA16FDD1E5F089100332277 /* SearchTest.swift */; };
2F13E79B1AC0C02700D75081 /* StringExtensionsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2F13E79A1AC0C02700D75081 /* StringExtensionsTests.swift */; };
Expand Down Expand Up @@ -397,7 +398,6 @@
D32A350E1D6530D80066DAE9 /* FxADevice.swift in Sources */ = {isa = PBXBuildFile; fileRef = D32A350D1D6530D80066DAE9 /* FxADevice.swift */; };
D32CACED1AE04DA1000658EB /* TestSwiftData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D32CACEC1AE04DA1000658EB /* TestSwiftData.swift */; };
D331DFCA1CB6E9EE009B5DA2 /* OldStrings.swift in Sources */ = {isa = PBXBuildFile; fileRef = D331DFC91CB6E9EE009B5DA2 /* OldStrings.swift */; };
D343DCD91C445EE600D7EEE8 /* FindInPageTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D343DCD81C445EE600D7EEE8 /* FindInPageTests.swift */; };
D343DCFE1C446BDB00D7EEE8 /* findPage.html in Resources */ = {isa = PBXBuildFile; fileRef = D343DCFD1C446BDB00D7EEE8 /* findPage.html */; };
D34510881ACF415700EC27F0 /* SearchLoader.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34510871ACF415700EC27F0 /* SearchLoader.swift */; };
D34DC8531A16C40C00D49B7B /* Profile.swift in Sources */ = {isa = PBXBuildFile; fileRef = D34DC84D1A16C40C00D49B7B /* Profile.swift */; };
Expand Down Expand Up @@ -1317,6 +1317,7 @@
28FDFF0B1C1F725800840F86 /* SeparatorTableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SeparatorTableCell.swift; sourceTree = "<group>"; };
2C2A5EF31E68469500F02659 /* PrivateBrowsingTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PrivateBrowsingTest.swift; sourceTree = "<group>"; };
2C3406C71E719F00000FD889 /* SettingsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SettingsTest.swift; sourceTree = "<group>"; };
2C8C07761E7800EA00DC1237 /* FindInPageTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FindInPageTest.swift; sourceTree = "<group>"; };
2C97EC701E72C80E0092EC18 /* TopTabsTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TopTabsTest.swift; sourceTree = "<group>"; };
2CA16FDD1E5F089100332277 /* SearchTest.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchTest.swift; sourceTree = "<group>"; };
2F13E79A1AC0C02700D75081 /* StringExtensionsTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StringExtensionsTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1564,7 +1565,6 @@
D32A350D1D6530D80066DAE9 /* FxADevice.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FxADevice.swift; sourceTree = "<group>"; };
D32CACEC1AE04DA1000658EB /* TestSwiftData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestSwiftData.swift; sourceTree = "<group>"; };
D331DFC91CB6E9EE009B5DA2 /* OldStrings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OldStrings.swift; sourceTree = "<group>"; };
D343DCD81C445EE600D7EEE8 /* FindInPageTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = FindInPageTests.swift; sourceTree = "<group>"; };
D343DCFD1C446BDB00D7EEE8 /* findPage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = findPage.html; sourceTree = "<group>"; };
D34510871ACF415700EC27F0 /* SearchLoader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SearchLoader.swift; sourceTree = "<group>"; };
D34DC84D1A16C40C00D49B7B /* Profile.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Profile.swift; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.swift; };
Expand Down Expand Up @@ -2632,6 +2632,7 @@
2C2A5EF31E68469500F02659 /* PrivateBrowsingTest.swift */,
2CA16FDD1E5F089100332277 /* SearchTest.swift */,
2C97EC701E72C80E0092EC18 /* TopTabsTest.swift */,
2C8C07761E7800EA00DC1237 /* FindInPageTest.swift */,
);
path = XCUITests;
sourceTree = "<group>";
Expand Down Expand Up @@ -2865,7 +2866,6 @@
E6B4C4021C68F58B001F97E8 /* BrowserTests.swift */,
7B24DC9B1B67B3590005766B /* ClearPrivateDataTests.swift */,
D313BE971B2F5096009EF241 /* DomainAutocompleteTests.swift */,
D343DCD81C445EE600D7EEE8 /* FindInPageTests.swift */,
D39FA1801A83E84900EE869C /* Global.swift */,
4F514FD31ACD8F2C0022D7EA /* HistoryTests.swift */,
39F6D06F1CD3B0770055D949 /* HomePageSettingsUITests.swift */,
Expand Down Expand Up @@ -4975,6 +4975,7 @@
39EB469A1E26DDB4006346E8 /* FxScreenGraph.swift in Sources */,
0B729D371E047D6A008E6859 /* HomePageSettingsTest.swift in Sources */,
55A747171DC46FC400CE1B57 /* HomePageUITest.swift in Sources */,
2C8C07771E7800EA00DC1237 /* FindInPageTest.swift in Sources */,
2C3406C81E719F00000FD889 /* SettingsTest.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -5007,7 +5008,6 @@
files = (
0B5A93221B1EB4C8004F47A2 /* ReadingListTest.swift in Sources */,
D38F03701C06387900175932 /* AuthenticationTests.swift in Sources */,
D343DCD91C445EE600D7EEE8 /* FindInPageTests.swift in Sources */,
28C8B7851C852535006D8318 /* BookmarksPanelTests.swift in Sources */,
E6B4C4031C68F58B001F97E8 /* BrowserTests.swift in Sources */,
D39FA1811A83E84900EE869C /* Global.swift in Sources */,
Expand Down
Expand Up @@ -47,6 +47,9 @@
ReferencedContainer = "container:Client.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "LivePushClientTests">
</Test>
<Test
Identifier = "SyncAuthStateTests/testLive()">
</Test>
Expand Down
122 changes: 0 additions & 122 deletions UITests/FindInPageTests.swift

This file was deleted.

113 changes: 113 additions & 0 deletions XCUITests/FindInPageTest.swift
@@ -0,0 +1,113 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import XCTest

class FindInPageTests: BaseTestCase {
var navigator: Navigator!
var app: XCUIApplication!

override func setUp() {
super.setUp()
app = XCUIApplication()
navigator = createScreenGraph(app).navigator(self)
}

override func tearDown() {
super.tearDown()
}

private func openFindInPageFromMenu() {
navigator.goto(BrowserTabMenu)
let collectionViewsQuery = app.collectionViews
waitforExistence(collectionViewsQuery.cells["Find In Page"])

collectionViewsQuery.cells["Find In Page"].tap()
XCTAssertTrue(app.textFields[""].exists)
}

func testFindFromMenu() {
openFindInPageFromMenu()
// Enter some text to start finding
app.textFields[""].typeText("Book")

// Once there are matches, test previous/next buttons
waitforExistence(app.staticTexts["1/5"])
XCTAssertTrue(app.staticTexts["1/5"].exists)

let nextInPageResultButton = app.buttons["Next in-page result"]
nextInPageResultButton.tap()
waitforExistence(app.staticTexts["2/5"])
XCTAssertTrue(app.staticTexts["2/5"].exists)

nextInPageResultButton.tap()
waitforExistence(app.staticTexts["3/5"])
XCTAssertTrue(app.staticTexts["3/5"].exists)

let previousInPageResultButton = app.buttons["Previous in-page result"]
previousInPageResultButton.tap()

waitforExistence(app.staticTexts["2/5"])
XCTAssertTrue(app.staticTexts["2/5"].exists)

previousInPageResultButton.tap()
waitforExistence(app.staticTexts["1/5"])
XCTAssertTrue(app.staticTexts["1/5"].exists)

// Tapping on close dismisses the search bar
app.buttons["Done"].tap()
waitforNoExistence(app.textFields["Book"])
}

func testQueryWithNoMatches() {
openFindInPageFromMenu()

// Try to find text which does not match and check that there are not results
app.textFields[""].typeText("foo")
waitforExistence(app.staticTexts["0/0"])
XCTAssertTrue(app.staticTexts["0/0"].exists, "There should not be any matches")
}

func testBarDissapearsWhenReloading() {
openFindInPageFromMenu()

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

// Once the page is reloaded the search bar should not appear
waitforNoExistence(app.textFields[""])
XCTAssertFalse(app.textFields[""].exists)
}

func testBarDissapearsWhenOpeningTabsTray() {
openFindInPageFromMenu()

// Going to tab tray and back to the website hides the search field.
navigator.nowAt(BrowserTab)
navigator.goto(TabTray)

waitforExistence(app.collectionViews.cells["The Book of Mozilla"])
app.collectionViews.cells["The Book of Mozilla"].tap()
XCTAssertFalse(app.textFields[""].exists)
}

func testFindFromSelection() {
navigator.goto(BrowserTab)
let textToFind = "from"

// Long press on the word to be found
let stringToFind = app.webViews.staticTexts.matching(identifier: textToFind)
let firstStringToFind = stringToFind.element(boundBy: 0)
firstStringToFind.press(forDuration: 5)

// Find in page is correctly launched, bar with text pre-filled and the buttons to find next and previous
waitforExistence(app.menuItems["Find in Page"])
app.menuItems["Find in Page"].tap()
waitforExistence(app.textFields[textToFind])
XCTAssertTrue(app.textFields[textToFind].exists, "The bar does not appear with the text selected to be found")
XCTAssertTrue(app.buttons["Previous in-page result"].exists, "Find previus button exists")
XCTAssertTrue(app.buttons["Next in-page result"].exists, "Find next button exists")
}
}
4 changes: 2 additions & 2 deletions XCUITests/ThirdPartySearchTest.swift
Expand Up @@ -24,7 +24,7 @@ class ThirdPartySearchTest: BaseTestCase {
app.buttons["Dismiss"].tap()
}
}

/* Three test cases disabled because they are failing due to a known bug: 1349154, they will be enabled again once it is fixed
func testCustomSearchEngines() {
let app = XCUIApplication()
Expand Down Expand Up @@ -129,7 +129,7 @@ class ThirdPartySearchTest: BaseTestCase {
XCTAssertFalse(app.scrollViews.otherElements.buttons["developer.mozilla.org search"].exists)
}

*/
func testCustomEngineFromCorrectTemplate() {
let app = XCUIApplication()

Expand Down

0 comments on commit acdd7a2

Please sign in to comment.