Skip to content
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

Remove calls to WebStorage JS methods, fixes #2772 #2773

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 10 additions & 18 deletions lib/capybara/selenium/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -353,29 +353,21 @@ def clear_storage
end

def clear_session_storage
if @browser.respond_to? :session_storage
@browser.session_storage.clear
else
begin
@browser&.execute_script('window.sessionStorage.clear()')
rescue # rubocop:disable Style/RescueStandardError
unless options[:clear_session_storage].nil?
warn 'sessionStorage clear requested but is not supported by this driver'
end
begin
@browser&.execute_script('window.sessionStorage.clear()')
rescue # rubocop:disable Style/RescueStandardError
unless options[:clear_session_storage].nil?
warn 'sessionStorage clear requested but is not supported by this driver'
end
end
end

def clear_local_storage
if @browser.respond_to? :local_storage
@browser.local_storage.clear
else
begin
@browser&.execute_script('window.localStorage.clear()')
rescue # rubocop:disable Style/RescueStandardError
unless options[:clear_local_storage].nil?
warn 'localStorage clear requested but is not supported by this driver'
end
begin
@browser&.execute_script('window.localStorage.clear()')
rescue # rubocop:disable Style/RescueStandardError
unless options[:clear_local_storage].nil?
warn 'localStorage clear requested but is not supported by this driver'
end
end
end
Expand Down