-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
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
[rb] Add target type param to devtools #15416
[rb] Add target type param to devtools #15416
Conversation
Previously only a target_type of 'page' was supported. By adding target_type as an optional paramater that defaults to 'page', the network conditions on a service worker can be set eg ```ruby devtools(target_type: 'service_worker').network.emulate_network_conditions( offline: true, latency: 0, download_throughput: 0, upload_throughput: 0 ) ```
@p0deje I've sketched out your suggestion and happy to adapt as necessary. Not sure about documentation as I couldn't find a place where it would go but I might have missed it. |
@jpawlyn That's pretty cool and exactly what I had in mind! I'll be happy to merge as long as CI passes. |
Great. One minor improvement is possibly testing for an unknown |
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
since map is not adding anything
Can you please fix?
|
Previously only a target_type of 'page' was supported. By adding target_type as an optional parameter that defaults to 'page', the network conditions on a service worker can be set, eg ```ruby devtools(target_type: 'service_worker').network.emulate_network_conditions( offline: true, latency: 0, download_throughput: 0, upload_throughput: 0 ) ```
User description
Motivation and Context
Testing offline functionality of pages cached by a service worker in a Rails app entailed using a monkey patch. Ideally the code from the monkey patch could be added to the ruby gem which is what this PR does.
To test offline functionality for a service worker we want to be able to call the following:
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
Added
target_type
parameter to DevTools for flexibility.Enhanced DevTools initialization to support multiple target types.
Improved error handling for unsupported target types.
Added integration tests for new
target_type
functionality.Changes walkthrough 📝
driver.rb
Update `quit` to handle multiple DevTools connections
rb/lib/selenium/webdriver/common/driver.rb
quit
method to close all DevTools connections.has_devtools.rb
Add `target_type` parameter to `devtools` method
rb/lib/selenium/webdriver/common/driver_extensions/has_devtools.rb
target_type
parameter todevtools
method.devtools.rb
Enhance DevTools to support multiple target types
rb/lib/selenium/webdriver/devtools.rb
initialize
to accepttarget_type
.start_session
to handle different target types.devtools_spec.rb
Add integration tests for `target_type` in DevTools
rb/spec/integration/selenium/webdriver/devtools_spec.rb
target_type
.target_type
.service_worker.html
Add test page for service worker functionality
common/src/web/service_worker.html