Skip to content
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 1 commit into from
Dec 30, 2019

Conversation

SimonBasca
Copy link
Contributor

Updated tests after #5848 - Remove add search engine button from keyboard #5858

@isabelrios
Copy link
Contributor

Hi @SimonBasca! thanks for this PR! the tests look good but they are not working on iOS 13.3 simulator, at least on my side :( could you please double check?
It is possible to enter the custom search engine name and tap on the url field but then, nothing is written there. I'm investigating that issue...

app.tables.textViews["customEngineTitle"].staticTexts["Search Engine"].tap()
app.typeText("Mozilla Engine")
app.tables.textViews["customEngineUrl"].staticTexts["URL (Replace Query with %s)"].tap()
app.typeText("https://developer.mozilla.org/search?q=%s")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this typeText working...there is this workaround instead that we could use:

           UIPasteboard.general.string = "https://developer.mozilla.org/search?q=%s"
            
            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()

In this case, the tap on Save button has to be moved to the tests otherwise there was a failure trying to tap there (in the graph we can't add a waitFor, and so the only solution was to add sleep or move the tap on Save button to the test)

dismissKeyboardAssistant(forApp: app)
}

navigator.performAction(Action.AddCustomSearchEngine)
Copy link
Contributor

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:

waitForExistence(app.buttons["customEngineSaveButton"], timeout: 3)
app.buttons["customEngineSaveButton"].tap()

navigator.openNewURL(urlString:"window")
app.textFields["url"].tap()
waitForExistence(app.buttons["urlBar-cancel"])
app.typeText("window")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't get this typeText working either... Similar solution as above could be:

UIPasteboard.general.string = "window"
app.textFields.firstMatch.press(forDuration: 1)
app.staticTexts["Paste & Go"].tap()

waitForExistence(app.textFields["url"], timeout: 3)
navigator.performAction(Action.AddCustomSearchEngine)
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above, but in this case we don't have to go to the url, so only Paste is needed:

UIPasteboard.general.string = "window"
app.textFields.firstMatch.press(forDuration: 1)
app.staticTexts["Paste"].tap()

// 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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, we need to change how to write text in the url bar:

UIPasteboard.general.string = "window"
app.textFields.firstMatch.press(forDuration: 1)
app.staticTexts["Paste"].tap()

}

func testCustomEngineFromIncorrectTemplate() {
navigator.goto(SearchSettings)
app.tables.cells["customEngineViewButton"].tap()
navigator.goto(AddCustomSearchSettings)
app.textViews["customEngineTitle"].tap()
app.typeText("Feeling Lucky")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And here, we need to use the workaround again:

        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()

// 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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeText not working...using this workaround we get same results:

UIPasteboard.general.string = "window"
app.textFields.firstMatch.press(forDuration: 1)
app.staticTexts["Paste"].tap()

Copy link
Contributor

@isabelrios isabelrios left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As commented on Slack, there are different issues with typeText after the iOS 13.3 update. I have found a few workarounds for those issues. You can find them in the comments and since there are a few, I will commit the changes (not final, still some comments and so in case tests can be improved after you check them) so that we don't loose the how to fix the tests :)

@SimonBasca
Copy link
Contributor Author

Hi @SimonBasca! thanks for this PR! the tests look good but they are not working on iOS 13.3 simulator, at least on my side :( could you please double check?
It is possible to enter the custom search engine name and tap on the url field but then, nothing is written there. I'm investigating that issue...

I ran the tests several times and in my case, every time the URL was written in the field. I only encountered one intermittent failure for testCustomSearchEngineAsDefault. Several times the the Mozilla search engine was not added as default. With the changes I did it should be working fine now.

using workaround to fix typeText issues

forgot tap and check

fix delete custom search engine

Cleanup
@SimonBasca SimonBasca force-pushed the sbasca/Fix3rdPartySearchEngineTest branch from 4a4d47e to 6c15c3d Compare December 30, 2019 15:09
@isabelrios
Copy link
Contributor

Changes addressed and everything looking good + all tests green!

@isabelrios isabelrios merged commit e19cb0c into master Dec 30, 2019
garvankeeley added a commit that referenced this pull request Jan 1, 2020
…pon reload/URL traversal, hook up onStartLoad (#5970)

* Fix #5848: Remove add search engine button from keyboard (#5857)

* Fix #5868 update onepassword in carthage (#5870)

* change source of onepassword-app-extension and update

* Update Cartfile

* Update Cartfile.resolved

* Fix: Expression implicitly coerced from '[String : Any?]' to '[String : Any]' (#5876)

* Add Fragment Support for Search Terms  (#5847)

* add fragment support for search engine

* refactor and re indent file

* add test case of fragment usage for search term

* Revert "Fix #5868 update onepassword in carthage (#5870)" (#5883)

This reverts commit 13c3398.

* Fix #5877 [iPad][iOS 12.x] Library panel buttons are cut off

* Organize LibraryViewController into separate files

* Fix #5868: update 1pw in cartfile (#5884)

* Fix UIView.isHidden must be used from main thread only (#5875)

* Fix UIView.isHidden must be used from main thread only

* Revert "Fix UIView.isHidden must be used from main thread only"

This reverts commit e5ce847.

* FirefoxAccountStateChange post notification wrapped to notify on the main thread.

* Fix #5877 - [iPad][iOS 12.x] Library panel buttons are cut off (#5886)

* Fix #5826 - XCUITests fail to type in URL bar (#5831)

* Fix #5826 - XCUITests fail to type in URL bar

* waitfor textfield url before typing

* change url for address

* try tapping on address textField first

* new fixes

* using firstMatch instead of address or url

* trying to find  workaround

* more fixes

* wait longer for webview to be loaded

* comment workaround

* fix waiting for fxaccount website

* removing sleep

* Fix: Expression implicitly coerced from '[String : Any?]' to '[String : Any]' (#5876)

* Add Fragment Support for Search Terms  (#5847)

* add fragment support for search engine

* refactor and re indent file

* add test case of fragment usage for search term

* Revert "Fix #5868 update onepassword in carthage (#5870)" (#5883)

This reverts commit 13c3398.

* Fix #5868: update 1pw in cartfile (#5884)

* Fix UIView.isHidden must be used from main thread only (#5875)

* Fix UIView.isHidden must be used from main thread only

* Revert "Fix UIView.isHidden must be used from main thread only"

This reverts commit e5ce847.

* FirefoxAccountStateChange post notification wrapped to notify on the main thread.

* Fix #5826 - XCUITests fail to type in URL bar (#5831)

* Fix #5826 - XCUITests fail to type in URL bar

* waitfor textfield url before typing

* change url for address

* try tapping on address textField first

* new fixes

* using firstMatch instead of address or url

* trying to find  workaround

* more fixes

* wait longer for webview to be loaded

* comment workaround

* fix waiting for fxaccount website

* removing sleep

* Fix #5823 (#5861)

Firefox loses URL when opening a link in a new tab without internet connection #5823

* Fix #5508 Add Unit tests for Everything and Today and Yesterday options for Clear Recent History, as well as test to validate that all expected options are shown for Clear Recent History (#5899)

* Fix #5679 - Added ability for user remove an account if they are unable to verify email (#5897)

- Added account removal alert

- Moved UserDefaults Prefs helper to Shared so that we can easily write Profile / Account unit tests

- Added a MockAccount class to mock the Firefox account for testing purposes

* Fix #5904: UIView.isHidden must be used from main thread (#5906)

* Fix #5866 if the webpage has low-res favicon, show default icon

Changed to favicon to be displayed size minimum of 32x32 in TopSites

* Fix #5862 - Reading list text is not fully displayed in landscapeMode (#5872)

* Fix #5902 - XCUITests more iOS13 fixes (#5903)

* Fix #5902 - XCUITests more iOS13 fixes

* adding sleep

* remove sleep and increase timeout

* fix smoketest

* Fix #5869 - The  button from the toast notification is too small (#5895)

* Fix #5869 - The  button from the toast notification is too small

* ButtonToast size change

* Fix #5888 - QR code frame is not aligned (#5922)

* Fix #5915 - Doesn't build on latest Xcode (#5932)

- Updated application-services to v0.47.0

* Issue #5753: Separated contributing from readme (#5929)

* seperated contributing from readme

* Removed upercase in "CONTRIBUTING"

* Fix #5781 - [iPad] Tabs tray layout is not correct when entering split screen (#5925)

* Bug 1604804: blob download (#5935)

* Fix #5559 - use special fingerprinting list / refactor python code to swift (#5936)

* Port content blocker python code to swift

* remove python file

* Change build scripts

* add license header

* Fix #5928: Land strings for v22 cover sheet (#5943)

* NoIssue-TryingToFixXcode11.3TestsFailures (#5939)

* NoIssue-TryingToFixXcode11.3TestsFailures

* disable sync and translation tests

* new fixes for navigation, private browsing and tp

* fix for dataManagement, domain autocomplete, homepagesettings

* fix dataManagement, navigation and sync ui tests

* Remove camera view when moving to non-XR site

* Wired up "Stop AR" menu button with new web method

* “Fix (#5948)

using workaround to fix typeText issues

forgot tap and check

fix delete custom search engine

Cleanup

* Move applicationName as FxiOS to property (#5955)

* Fix #5237 - 'Recent Bookmarks' header should match other table view headers (#5960)

* Remove obsolete usingMetal, useMetalForARKey

* Pause ARSession upon reload/URL traversal

* Run onStartLoad when didStartProvisionalNavigation

* Removed xrStopAR tabAction

Co-authored-by: Mustafa Hastürk <[email protected]>
Co-authored-by: Daniela Arcese <[email protected]>
Co-authored-by: Garvan Keeley <[email protected]>
Co-authored-by: Nishant Bhasin <[email protected]>
Co-authored-by: isabelrios <[email protected]>
Co-authored-by: dfperry5 <[email protected]>
Co-authored-by: Yuşa Doğru <[email protected]>
Co-authored-by: KrystynaKruchkovska <[email protected]>
Co-authored-by: Harsh Mehta <[email protected]>
Co-authored-by: SimonBasca <[email protected]>
Co-authored-by: Mykola Aleshchenko <[email protected]>
@SimonBasca SimonBasca deleted the sbasca/Fix3rdPartySearchEngineTest branch February 13, 2020 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants