From 9e8c7b3ecdf5358f6e04e741c3ccb33d21215568 Mon Sep 17 00:00:00 2001 From: titusfortner Date: Tue, 28 Sep 2021 09:37:29 -0500 Subject: [PATCH] [rb] use file detector for uploading add-ons if one is set --- rb/lib/selenium/webdriver/firefox/features.rb | 5 +++++ .../integration/selenium/webdriver/firefox/driver_spec.rb | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/rb/lib/selenium/webdriver/firefox/features.rb b/rb/lib/selenium/webdriver/firefox/features.rb index a4c571340e2ec..9135c7968960f 100644 --- a/rb/lib/selenium/webdriver/firefox/features.rb +++ b/rb/lib/selenium/webdriver/firefox/features.rb @@ -35,6 +35,11 @@ def commands(command) end def install_addon(path, temporary) + if @file_detector + local_file = @file_detector.call(path) + path = upload(local_file) if local_file + end + payload = {path: path} payload[:temporary] = temporary unless temporary.nil? execute :install_addon, {}, payload diff --git a/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb b/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb index 97192d79c640f..78ced6abf8e21 100644 --- a/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb +++ b/rb/spec/integration/selenium/webdriver/firefox/driver_spec.rb @@ -42,6 +42,12 @@ module Firefox page: {width: 30})).to include(magic_number) end + it 'can add and remove addons' do + ext = File.expand_path('../../../../../../third_party/firebug/favourite_colour-1.1-an+fx.xpi', __dir__) + driver.install_addon(ext) + driver.uninstall_addon('favourite-colour-examples@mozilla.org') + end + it 'should print full page' do path = "#{Dir.tmpdir}/test#{SecureRandom.urlsafe_base64}.png" screenshot = driver.save_full_page_screenshot(path)