diff --git a/rb/lib/selenium/webdriver/remote/bridge.rb b/rb/lib/selenium/webdriver/remote/bridge.rb index 74385dabb920c..a26bb4bd1fe22 100644 --- a/rb/lib/selenium/webdriver/remote/bridge.rb +++ b/rb/lib/selenium/webdriver/remote/bridge.rb @@ -301,6 +301,7 @@ def element_screenshot(element) # def local_storage_item(key, value = nil) + WebDriver.logger.deprecate('local_storage_item(key, value)', id: :local_storage_item) if value execute_script("localStorage.setItem('#{key}', '#{value}')") else @@ -309,22 +310,27 @@ def local_storage_item(key, value = nil) end def remove_local_storage_item(key) + WebDriver.logger.deprecate('remove_local_storage_item(key)', id: :remove_local_storage_item) execute_script("localStorage.removeItem('#{key}')") end def local_storage_keys + WebDriver.logger.deprecate('local_storage_keys', id: :local_storage_keys) execute_script('return Object.keys(localStorage)') end def clear_local_storage + WebDriver.logger.deprecate('clear_local_storage', id: :clear_local_storage) execute_script('localStorage.clear()') end def local_storage_size + WebDriver.logger.deprecate('local_storage_size', id: :local_storage_size) execute_script('return localStorage.length') end def session_storage_item(key, value = nil) + WebDriver.logger.deprecate('session_storage_item(key, value)', id: :session_storage_item) if value execute_script("sessionStorage.setItem('#{key}', '#{value}')") else @@ -333,18 +339,22 @@ def session_storage_item(key, value = nil) end def remove_session_storage_item(key) + WebDriver.logger.deprecate('remove_session_storage_item(key)', id: :remove_session_storage_item) execute_script("sessionStorage.removeItem('#{key}')") end def session_storage_keys + WebDriver.logger.deprecate('session_storage_keys', id: :session_storage_keys) execute_script('return Object.keys(sessionStorage)') end def clear_session_storage + WebDriver.logger.deprecate('clear_session_storage', id: :clear_session_storage) execute_script('sessionStorage.clear()') end def session_storage_size + WebDriver.logger.deprecate('session_storage_size', id: :session_storage_size) execute_script('return sessionStorage.length') end diff --git a/rb/spec/integration/selenium/webdriver/storage_spec.rb b/rb/spec/integration/selenium/webdriver/storage_spec.rb index a438984eb9706..dfa4762452bbb 100644 --- a/rb/spec/integration/selenium/webdriver/storage_spec.rb +++ b/rb/spec/integration/selenium/webdriver/storage_spec.rb @@ -99,6 +99,17 @@ module DriverExtensions storage.fetch('no-such-key') }.to raise_error(IndexError, /missing key/) end + + it 'logs a deprecated warning when calling a deprecated method' do + storage_type = storage.is_a?(HTML5::LocalStorage) ? 'local' : 'session' + + expect { storage['foo'] }.to have_deprecated(:"#{storage_type}_storage_item") + expect { storage['foo'] = 'bar' }.to have_deprecated(:"#{storage_type}_storage_item") + expect { storage.delete('foo') }.to have_deprecated(:"remove_#{storage_type}_storage_item") + expect { storage.size }.to have_deprecated(:"#{storage_type}_storage_size") + expect { storage.clear }.to have_deprecated(:"clear_#{storage_type}_storage") + expect { storage.keys }.to have_deprecated(:"#{storage_type}_storage_keys") + end end describe 'local storage' do