-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
fix flaky Ruby test devtools_spec.rb
#16693
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
Conversation
Wait until service worker gets registered. Sometimes it's slow and can take more than 0.5 seconds.
Example of failure:
```ruby
Failures:
1) Selenium::WebDriver::DevTools#target target type is service_worker
Failure/Error: target = driver.devtools(target_type: 'service_worker').target
Selenium::WebDriver::Error::WebDriverError:
Target type 'service_worker' not found
# ./rb/lib/selenium/webdriver/devtools.rb:87:in `start_session'
# ./rb/lib/selenium/webdriver/devtools.rb:34:in `initialize'
# ./rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb:36:in `new'
# ./rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb:36:in `devtools'
# ./rb/spec/integration/selenium/webdriver/devtools_spec.rb:66:in `block (3 levels) in <module:WebDriver>'
```
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:
|
||||||||||||
User description
Wait until service worker gets registered. Sometimes it's slow and can take more than 0.5 seconds.
Example of failure:
@jpawlyn FYI
🔗 Related Issues
For example, this build failed:
https://github.com/SeleniumHQ/selenium/actions/runs/19984104789/job/57315854174
💥 What does this PR do?
WebDriverError "Target type 'unknown' not found", now a more specific subclassNoSuchTargetError "Target type 'unknown' not found"is thrown.🔄 Types of changes
PR Type
Bug fix, Tests
Description
Add
NoSuchTargetErrorexception for missing DevTools targetsReplace hardcoded sleep with proper wait mechanism for service worker registration
Introduce
wait_for_devtools_targethelper for reliable target detectionDelay service worker registration by 100ms to catch timing issues early
Diagram Walkthrough
File Walkthrough
error.rb
Add NoSuchTargetError exception classrb/lib/selenium/webdriver/common/error.rb
NoSuchTargetErrorexception class for DevTools target lookupfailures
WebDriverErrorhelpers.rb
Add wait_for_devtools_target helper methodrb/spec/integration/selenium/webdriver/spec_support/helpers.rb
wait_for_devtools_targethelper method with 3-second timeoutWaitwithignoreparameter to handleNoSuchTargetErrorgracefullyavailability
devtools.rb
Use NoSuchTargetError for target lookuprb/lib/selenium/webdriver/devtools.rb
WebDriverErrortoNoSuchTargetErrorinstart_sessionmethoddevtools_spec.rb
Replace sleep with proper wait helperrb/spec/integration/selenium/webdriver/devtools_spec.rb
sleep 0.5withwait_for_devtools_targethelper callNoSuchTargetErrorexceptiontype
service_worker.html
Add 100ms delay to service worker registrationcommon/src/web/service_worker.html
setTimeoutwith 100ms delay