Conversation
Contributor
Author
|
I already ran few builds with these changes. Although it is difficult to tell whether the flakiness is any different, there are no obvious problems. |
…ithout waiting seconds_to_wait
206e283 to
223ff5a
Compare
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Capybara has a method called
Capybara::Base#synchronize. This method waits a certain amount of time for a block to be executed without exceptions. It also rescues common exceptions and automatically retries them. All in the name of more stable tests.AePageObjects includes a helper method
#wait_untilwhich waits a certain amount of time for a block to return something truthy.It also includes the method
#poll_until(which builds on#wait_until) to quickly poll the browser for the truthy answer. It does this withCapybara.using_time_out(0). This method is currently only used internally in AePageObjects to implementwindow.change_tobehavior and element proxy behavior.The currently implementation (
ae_page_objects/lib/ae_page_objects/util/page_polling.rb
Line 6 in c17d020
Capybara.using_time_out(0), which causesCapybara::Base#synchronizeto not rescue any common exceptions (and instead letting them be raised). This means thatwindow.change_tocan raise exceptions instead of retrying to evaluate its conditions until one of them evaluates to true.This problem can be seen in the other usage of
#poll_untilin element proxy (ae_page_objects/lib/ae_page_objects/element_proxy.rb
Line 142 in c17d020
#reload_elementtries to catch and retrySelenium::WebDriver::Error::StaleElementReferenceError.This PRs improves
#poll_untilmethod to rescue and retry common errors (much likeCapybara::Base#synchronize). This allows to wait the appropriate amount of time for the page / browser to "settle" down and allow us to evaluate the conditions properly.This PRs also introduces
#pollmethod as a safer alternative to the following pattern,This is commonly used to try to determine whether a page is in a certain state (without having to wait for that state to become true) in order to switch page object functionality. For example, accessing the main nav actions on mobile may be slightly different then accessing nav actions on desktop. The page object can abstract these differences from the actual tests but it needs a way to quickly determine which version of the page we're using.