You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
Based on #10397 this PR tries to deprecated all the methods that uses JS to interact with the web storage
Motivation and Context
It's important that all bindings interact with the web storage APIs in the same way, so the first step is to align on what should be deprecated or removed
Types of changes
Bug fix (non-breaking change which fixes an issue)
New feature (non-breaking change which adds functionality)
Breaking change (fix or feature that would cause existing functionality to change)
Added deprecation warnings for various WebStorage JS methods in rb/lib/selenium/webdriver/remote/bridge.rb.
Implemented tests in rb/spec/integration/selenium/webdriver/storage_spec.rb to verify that deprecation warnings are logged when deprecated methods are called.
Changes walkthrough 📝
Relevant files
Enhancement
bridge.rb
Add deprecation warnings for WebStorage JS methods
rb/lib/selenium/webdriver/remote/bridge.rb
Added deprecation warnings for local_storage_item, remove_local_storage_item, local_storage_keys, clear_local_storage, local_storage_size, session_storage_item, remove_session_storage_item, session_storage_keys, clear_session_storage, and session_storage_size methods.
Improve security by using parameterized script execution
Replace the direct string interpolation inside the execute_script method with parameterized script execution to prevent potential security risks like script injection.
-execute_script('localStorage.clear()')+begin+ execute_script('localStorage.clear()')+rescue => e+ WebDriver.logger.error("Failed to clear local storage: #{e.message}")+end
Apply this suggestion
Suggestion importance[1-10]: 9
Why: Adding error handling enhances the robustness of the code by managing potential JavaScript execution failures, which is important for reliability.
9
Enhancement
Enhance deprecation messages to guide users towards alternatives
Refactor the deprecation logging to include more descriptive messages that explain what changes are expected or what alternatives should be used.
-WebDriver.logger.deprecate('session_storage_item(key, value)', id: :session_storage_item)+WebDriver.logger.deprecate('session_storage_item with key and value is deprecated, use XYZ instead', id: :session_storage_item)
Apply this suggestion
Suggestion importance[1-10]: 8
Why: Providing more descriptive deprecation messages helps users understand what changes are needed and improves the overall developer experience.
8
Maintainability
Standardize deprecation logging for consistency
Use a consistent logging format or method for deprecation to ensure uniformity across the codebase. If WebDriver.logger.deprecate is a new standard, ensure it is used consistently or refactor existing logs to this format.
-WebDriver.logger.deprecate('local_storage_item(key, value)', id: :local_storage_item)+WebDriver.logger.deprecate('Using local_storage_item with key and value is deprecated', id: :local_storage_item)
Apply this suggestion
Suggestion importance[1-10]: 7
Why: Ensuring a consistent logging format improves code maintainability and readability, although it is not critical.
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.
User description
Description
Based on #10397 this PR tries to deprecated all the methods that uses JS to interact with the web storage
Motivation and Context
It's important that all bindings interact with the web storage APIs in the same way, so the first step is to align on what should be deprecated or removed
Types of changes
Checklist
PR Type
Enhancement, Tests
Description
rb/lib/selenium/webdriver/remote/bridge.rb
.rb/spec/integration/selenium/webdriver/storage_spec.rb
to verify that deprecation warnings are logged when deprecated methods are called.Changes walkthrough 📝
bridge.rb
Add deprecation warnings for WebStorage JS methods
rb/lib/selenium/webdriver/remote/bridge.rb
local_storage_item
,remove_local_storage_item
,local_storage_keys
,clear_local_storage
,local_storage_size
,session_storage_item
,remove_session_storage_item
,session_storage_keys
,clear_session_storage
, andsession_storage_size
methods.
storage_spec.rb
Add tests for deprecated WebStorage methods warnings
rb/spec/integration/selenium/webdriver/storage_spec.rb
WebStorage methods.