-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
Fix few more flaky ruby tests #16695
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
base: trunk
Are you sure you want to change the base?
Conversation
PR Compliance Guide 🔍Below is a summary of compliance checks for this PR:
Compliance status legend🟢 - Fully Compliant🟡 - Partial Compliant 🔴 - Not Compliant ⚪ - Requires Further Human Verification 🏷️ - Compliance label |
||||||||||||||||||||||||
PR Code Suggestions ✨Explore these optional code suggestions:
|
||||||||||||
d07716a to
275cf06
Compare
Wait until the page gets loaded and the element ges rendered.
Example of failure:
```ruby
Selenium::WebDriver::Element raises if different element receives click
Failure/Error: expect { driver.find_element(id: 'contents').click }.to raise_error(Error::ElementClickInterceptedError)
expected Selenium::WebDriver::Error::ElementClickInterceptedError, got #<Selenium::WebDriver::Error::NoSuchElementError:"no such element: Unable to locate element: {\"metho...it: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#nosuchelementexception"> with backtrace:
# ./rb/lib/selenium/webdriver/remote/response.rb:63:in `add_cause'
# ./rb/lib/selenium/webdriver/remote/response.rb:41:in `error'
# ./rb/lib/selenium/webdriver/remote/response.rb:52:in `assert_ok'
# ./rb/lib/selenium/webdriver/remote/response.rb:34:in `initialize'
# ./rb/lib/selenium/webdriver/remote/http/common.rb:103:in `new'
# ./rb/lib/selenium/webdriver/remote/http/common.rb:103:in `create_response'
# ./rb/lib/selenium/webdriver/remote/http/default.rb:103:in `request'
# ./rb/lib/selenium/webdriver/remote/http/common.rb:68:in `call'
# ./rb/lib/selenium/webdriver/remote/bridge.rb:625:in `execute'
# ./rb/lib/selenium/webdriver/remote/bridge.rb:493:in `find_element_by'
# ./rb/lib/selenium/webdriver/common/search_context.rb:71:in `find_element'
# ./rb/spec/integration/selenium/webdriver/element_spec.rb:34:in `block (3 levels) in <module:WebDriver>'
# ./rb/spec/integration/selenium/webdriver/element_spec.rb:34:in `block (2 levels) in <module:WebDriver>'
# ./rb/spec/integration/selenium/webdriver/element_spec.rb:34:in `block (2 levels) in <module:WebDriver>'
```
See https://github.com/SeleniumHQ/selenium/actions/runs/19987626355/job/57324241360?pr=13739 for example.
instead of sleeping for 0.5s, just wait for the needed title.
instead of sleeping for 2.5s, just wait for the needed logs.
275cf06 to
92fbd13
Compare
User description
🔗 Related Issues
e.g. failed build: https://github.com/SeleniumHQ/selenium/actions/runs/19987626355/job/57324241360?pr=13739
💥 What does this PR do?
Fixes few flaky Ruby tests
🔧 Implementation Notes
This PR adds few "waits" to Ruby tests.
🔄 Types of changes
PR Type
Bug fix, Tests
Description
Replace flaky
sleepcalls with explicit waits in Ruby testsAdd
wait_for_element()helper to ensure elements are rendered before interactionAdd
wait_for_title()helper for page navigation assertionsFix DevTools log event handling to extract args properly
Diagram Walkthrough
File Walkthrough
element_spec.rb
Replace direct element finds with wait helpersrb/spec/integration/selenium/webdriver/element_spec.rb
driver.find_element()calls withwait_for_element()helper to ensure elements are rendered
sleep 0.5calls withwait_for_title()helper for pagenavigation assertions
before interaction
devtools_spec.rb
Fix DevTools log test with waits and arg extractionrb/spec/integration/selenium/webdriver/devtools_spec.rb
sleep 0.5calls from console log testlog.args[0]instead of storingfull log object
wait.untilchecks for log valueshelpers.rb
Add wait_for_title helper methodrb/spec/integration/selenium/webdriver/spec_support/helpers.rb
wait_for_title()helper method with 5-second timeout