-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix #5858 - [XCUITests] Update tests after removing custom search engine icon #5948
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,22 +12,22 @@ class ThirdPartySearchTest: BaseTestCase { | |
} | ||
|
||
func testCustomSearchEngines() { | ||
// Visit MDN to add a custom search engine | ||
loadWebPage(mozDeveloperWebsite, waitForLoadToFinish: true) | ||
addSearchProvider() | ||
|
||
if !isTablet { | ||
dismissKeyboardAssistant(forApp: app) | ||
} | ||
|
||
navigator.performAction(Action.AddCustomSearchEngine) | ||
waitForExistence(app.buttons["customEngineSaveButton"], timeout: 3) | ||
app.buttons["customEngineSaveButton"].tap() | ||
|
||
waitForExistence(app.navigationBars["Search"].buttons["Settings"], timeout: 3) | ||
app.navigationBars["Search"].buttons["Settings"].tap() | ||
app.navigationBars["Settings"].buttons["AppSettingsTableViewController.navigationItem.leftBarButtonItem"].tap() | ||
// Perform a search using a custom search engine | ||
tabTrayButton(forApp: app).tap() | ||
app.buttons["TabTrayController.addTabButton"].tap() | ||
waitForExistence(app.textFields["url"], timeout: 3) | ||
app.textFields["url"].tap() | ||
waitForExistence(app.buttons["urlBar-cancel"]) | ||
app.typeText("window") | ||
app.scrollViews.otherElements.buttons["developer.mozilla.org search"].tap() | ||
UIPasteboard.general.string = "window" | ||
app.textFields.firstMatch.press(forDuration: 1) | ||
app.staticTexts["Paste"].tap() | ||
app.scrollViews.otherElements.buttons["Mozilla Engine search"].tap() | ||
waitUntilPageLoad() | ||
|
||
var url = app.textFields["url"].value as! String | ||
if url.hasPrefix("https://") == false { | ||
|
@@ -37,22 +37,25 @@ class ThirdPartySearchTest: BaseTestCase { | |
} | ||
|
||
func testCustomSearchEngineAsDefault() { | ||
// Visit MDN to add a custom search engine | ||
loadWebPage(mozDeveloperWebsite, waitForLoadToFinish: true) | ||
addSearchProvider() | ||
|
||
if !isTablet { | ||
dismissKeyboardAssistant(forApp: app) | ||
} | ||
navigator.performAction(Action.AddCustomSearchEngine) | ||
waitForExistence(app.buttons["customEngineSaveButton"], timeout: 3) | ||
app.buttons["customEngineSaveButton"].tap() | ||
|
||
// Go to settings and set MDN as the default | ||
navigator.goto(SearchSettings) | ||
app.tables.cells.element(boundBy: 0).tap() | ||
app.tables.staticTexts["developer.mozilla.org"].tap() | ||
navigator.goto(BrowserTab) | ||
waitForExistence(app.tables.staticTexts["Google"]) | ||
app.tables.staticTexts["Google"].tap() | ||
waitForExistence(app.tables.staticTexts["Mozilla Engine"]) | ||
app.tables.staticTexts["Mozilla Engine"].tap() | ||
DismissSearchScreen() | ||
|
||
// Perform a search to check | ||
navigator.openNewURL(urlString:"window") | ||
app.textFields["url"].tap() | ||
|
||
UIPasteboard.general.string = "window" | ||
app.textFields.firstMatch.press(forDuration: 1) | ||
app.staticTexts["Paste & Go"].tap() | ||
|
||
waitUntilPageLoad() | ||
|
||
// Ensure that the default search is MDN | ||
var url = app.textFields["url"].value as! String | ||
|
@@ -63,98 +66,61 @@ class ThirdPartySearchTest: BaseTestCase { | |
} | ||
|
||
func testCustomSearchEngineDeletion() { | ||
// Visit MDN to add a custom search engine | ||
loadWebPage(mozDeveloperWebsite, waitForLoadToFinish: true) | ||
addSearchProvider() | ||
navigator.performAction(Action.AddCustomSearchEngine) | ||
waitForExistence(app.buttons["customEngineSaveButton"], timeout: 3) | ||
app.buttons["customEngineSaveButton"].tap() | ||
|
||
if !isTablet { | ||
dismissKeyboardAssistant(forApp: app) | ||
} | ||
waitForExistence(app.navigationBars["Search"].buttons["Settings"], timeout: 3) | ||
|
||
let tabTrayButton = self.tabTrayButton(forApp: app) | ||
tabTrayButton.tap() | ||
app.buttons["TabTrayController.addTabButton"].tap() | ||
waitForExistence(app.textFields["url"], timeout: 3) | ||
app.navigationBars["Search"].buttons["Settings"].tap() | ||
app.navigationBars["Settings"].buttons["AppSettingsTableViewController.navigationItem.leftBarButtonItem"].tap() | ||
app.textFields["url"].tap() | ||
waitForExistence(app.buttons["urlBar-cancel"]) | ||
app.typeText("window") | ||
|
||
// For timing issue, we need a wait statement | ||
waitForExistence(app.scrollViews.otherElements.buttons["developer.mozilla.org search"]) | ||
XCTAssert(app.scrollViews.otherElements.buttons["developer.mozilla.org search"].exists) | ||
app.typeText("\r") | ||
|
||
// Go to settings and set MDN as the default | ||
waitUntilPageLoad() | ||
waitForNoExistence(app.alerts.buttons["Don't Allow"], timeoutValue: 15) | ||
waitForTabsButton() | ||
|
||
// Workaround for iOS13, can't go directly to BrowserTabMenu | ||
UIPasteboard.general.string = "window" | ||
app.textFields.firstMatch.press(forDuration: 1) | ||
app.staticTexts["Paste"].tap() | ||
waitForExistence(app.scrollViews.otherElements.buttons["Mozilla Engine search"]) | ||
XCTAssertTrue(app.scrollViews.otherElements.buttons["Mozilla Engine search"].exists) | ||
|
||
// Need to go step by step to Search Settings. The ScreenGraph will fail to go to the Search Settings Screen | ||
app.buttons["urlBar-cancel"].tap() | ||
app.buttons["TabToolbar.menuButton"].tap() | ||
navigator.goto(SearchSettings) | ||
|
||
app.navigationBars["Search"].buttons["Edit"].tap() | ||
app.tables.buttons["Delete developer.mozilla.org"].tap() | ||
app.tables.buttons["Delete"].tap() | ||
|
||
navigator.goto(BrowserTab) | ||
|
||
app.tables["Context Menu"].staticTexts["Settings"].tap() | ||
app.tables.staticTexts["Google"].tap() | ||
navigator.performAction(Action.RemoveCustomSearchEngine) | ||
DismissSearchScreen() | ||
|
||
// Perform a search to check | ||
tabTrayButton.tap(force: true) | ||
app.buttons["TabTrayController.addTabButton"].tap() | ||
waitForExistence(app.textFields["url"], timeout: 3) | ||
app.textFields["url"].tap() | ||
waitForExistence(app.buttons["urlBar-cancel"]) | ||
app.typeText("window") | ||
waitForNoExistence(app.scrollViews.otherElements.buttons["developer.mozilla.org search"]) | ||
XCTAssertFalse(app.scrollViews.otherElements.buttons["developer.mozilla.org search"].exists) | ||
} | ||
UIPasteboard.general.string = "window" | ||
app.textFields.firstMatch.press(forDuration: 1) | ||
app.staticTexts["Paste"].tap() | ||
|
||
private func addSearchProvider() { | ||
// Tap on the search field | ||
app.webViews.searchFields.element(boundBy: 0).tap() | ||
// Workaround due to issue #5442 | ||
if isTablet { | ||
app.buttons["Reload"].tap() | ||
waitUntilPageLoad() | ||
app.webViews.searchFields.element(boundBy: 0).tap() | ||
} | ||
app.buttons["AddSearch"].tap() | ||
app.alerts["Add Search Provider?"].buttons["OK"].tap() | ||
waitForExistence(app.buttons["AddSearch"], timeout: 3) | ||
XCTAssertFalse(app.buttons["AddSearch"].isEnabled) | ||
waitForNoExistence(app.scrollViews.otherElements.buttons["Mozilla Engine search"]) | ||
XCTAssertFalse(app.scrollViews.otherElements.buttons["Mozilla Engine search"].exists) | ||
} | ||
|
||
func testCustomEngineFromCorrectTemplate() { | ||
navigator.goto(SearchSettings) | ||
app.tables.cells["customEngineViewButton"].tap() | ||
|
||
app.textViews["customEngineTitle"].tap() | ||
app.typeText("Ask") | ||
app.textViews["customEngineUrl"].tap() | ||
app.typeText("http://www.ask.com/web?q=%s") | ||
app.navigationBars.buttons["customEngineSaveButton"].tap() | ||
|
||
// Perform a search using a custom search engine | ||
waitForExistence(app.tables.staticTexts["Ask"]) | ||
navigator.goto(HomePanelsScreen) | ||
app.textFields["url"].tap() | ||
app.typeText("strange charm") | ||
app.scrollViews.otherElements.buttons["Ask search"].tap() | ||
|
||
// Ensure that correct search is done | ||
let url = app.textFields["url"].value as! String | ||
XCTAssert(url.hasPrefix("www.ask.com"), "The URL should indicate that the search was performed using ask") | ||
|
||
private func DismissSearchScreen() { | ||
waitForExistence(app.navigationBars["Search"].buttons["Settings"]) | ||
app.navigationBars["Search"].buttons["Settings"].tap() | ||
app.navigationBars["Settings"].buttons["AppSettingsTableViewController.navigationItem.leftBarButtonItem"].tap() | ||
} | ||
|
||
func testCustomEngineFromIncorrectTemplate() { | ||
navigator.goto(SearchSettings) | ||
app.tables.cells["customEngineViewButton"].tap() | ||
navigator.goto(AddCustomSearchSettings) | ||
app.textViews["customEngineTitle"].tap() | ||
app.typeText("Feeling Lucky") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And here, we need to use the workaround again:
|
||
app.textViews["customEngineUrl"].tap() | ||
app.typeText("http://www.google.com/search?q=&btnI") //Occurunces of %s != 1 | ||
|
||
|
||
UIPasteboard.general.string = "http://www.google.com/search?q=&btnI" | ||
|
||
let tablesQuery = app.tables | ||
let customengineurlTextView = tablesQuery.textViews["customEngineUrl"] | ||
customengineurlTextView.staticTexts["URL (Replace Query with %s)"].tap() | ||
customengineurlTextView.press(forDuration: 1.0) | ||
app.staticTexts["Paste"].tap() | ||
sleep(2) | ||
app.navigationBars.buttons["customEngineSaveButton"].tap() | ||
|
||
waitForExistence(app.alerts.element(boundBy: 0)) | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After this line we would need to add: