-
Notifications
You must be signed in to change notification settings - Fork 103
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
Wait update #139
Merged
Merged
Wait update #139
Conversation
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
…med private methods to be more descriptive
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.
Timeout Errors:
Currently using all of the wait methods, if the Timeout is reached, the error gets swallowed up by the surrounding code and errors do not get printed to the logs.
This causes the tests using these methods to continue with their test as if nothing bad has happened.
Example:
In the above example, if the
wait_for_report
hits a timeout, the next linedownload_report
executes as if everything is okay.Current Landscape:
wait_until (71)
scanning status and scan integration, as well as waiting on UI elements.
wait_for_report (37)
generally only used when the next step is to download a CSV report, or verifying a report's status.
wait_for_integration (84)
used to wait for scan_status to become 'finished', or other passed in status.
sleep (35)
mostly seems to be used to slow down the UI after click events. however, other instances are used instead of the above methods.
Proposed Enhancements:
The Nexpose-client gem can contain the following Wait object, to help deal with the Timeout concerns.
Currently
Nexpose::Wait
has the following methods:for_report
for_integration
for_judgement
for_report
would replacewait_for_report
for_integration
would replacewait_for_integration
for_judgement
would hopefully mostly replacewait_until
So our example at the beginning for waiting on reports would look something like this now:
Or you could wrap
is_ready?
in an if block (shown with adjusting the timeout, and having it retry if it fails):Nexpose::Wait.new
Calling a new
Nexpose::Wait
object will allow you to initialize with the following options, which uses Ruby keyword arguments:error_message
: Overwrite the default error message.retry_count
: The number of times to retry the wait if we hit the timeout limit.timeout
: Number of seconds before we consider the request timed out.polling_interval
: Number of seconds to sleep before we retry to execute for the desired result.Nexpose::Wait.new( retry_count: 3, timeout: 120, polling_interval: 1 )
All
for_
methods support outputting an error message for timeouts, and additionally support API errors, and NoMethodErrors if reports or scans don't exist.Quick Win for Testing UI:
When using
find
during UI testing, pass inwait
to set timeout for finding that element.If it reaches the timeout, it will fail the test and log that it could not find the element in the allotted time.
Instead of this:
Try this:
Capybara also supports a number of other options when using
find