Module: Selenium::WebDriver::Firefox::Features
- Defined in:
- lib/selenium/webdriver/firefox/features.rb
Constant Summary collapse
- FIREFOX_COMMANDS =
{ get_context: [:get, 'session/:session_id/moz/context'], set_context: [:post, 'session/:session_id/moz/context'], install_addon: [:post, 'session/:session_id/moz/addon/install'], uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall'], full_page_screenshot: [:get, 'session/:session_id/moz/screenshot/full'] }.freeze
Instance Method Summary collapse
- #command_list ⇒ Object
- #commands(command) ⇒ Object
- #context ⇒ Object
- #context=(context) ⇒ Object
- #full_screenshot ⇒ Object
- #install_addon(path, temporary) ⇒ Object
- #install_web_extension(path, allow_private_browsing: nil, permanent: nil) ⇒ Object
- #uninstall_addon(id) ⇒ Object
- #uninstall_web_extension(extension_id) ⇒ Object
Instance Method Details
#command_list ⇒ Object
32 33 34 |
# File 'lib/selenium/webdriver/firefox/features.rb', line 32 def command_list FIREFOX_COMMANDS.merge(self.class::COMMANDS) end |
#commands(command) ⇒ Object
36 37 38 |
# File 'lib/selenium/webdriver/firefox/features.rb', line 36 def commands(command) command_list[command] end |
#context ⇒ Object
75 76 77 |
# File 'lib/selenium/webdriver/firefox/features.rb', line 75 def context execute :get_context end |
#context=(context) ⇒ Object
71 72 73 |
# File 'lib/selenium/webdriver/firefox/features.rb', line 71 def context=(context) execute :set_context, {}, {context: context} end |
#full_screenshot ⇒ Object
67 68 69 |
# File 'lib/selenium/webdriver/firefox/features.rb', line 67 def full_screenshot execute :full_page_screenshot end |
#install_addon(path, temporary) ⇒ Object
40 41 42 43 44 |
# File 'lib/selenium/webdriver/firefox/features.rb', line 40 def install_addon(path, temporary) payload = {addon: encode_extension(path)} payload[:temporary] = temporary unless temporary.nil? execute :install_addon, {}, payload end |
#install_web_extension(path, allow_private_browsing: nil, permanent: nil) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/selenium/webdriver/firefox/features.rb', line 50 def install_web_extension(path, allow_private_browsing: nil, permanent: nil) unless bidi? temporary = !permanent unless permanent.nil? = {temporary: temporary, allowPrivateBrowsing: allow_private_browsing}.compact return WebDriver::WebExtension.new(execute(:install_addon, {}, {addon: encode_extension(path), **})) end = {allow_private_browsing:, permanent:}.compact result = web_extension.moz.install(extension_data: web_extension_data(path), **) WebDriver::WebExtension.new(result.extension) end |
#uninstall_addon(id) ⇒ Object
46 47 48 |
# File 'lib/selenium/webdriver/firefox/features.rb', line 46 def uninstall_addon(id) execute :uninstall_addon, {}, {id: id} end |
#uninstall_web_extension(extension_id) ⇒ Object
62 63 64 65 |
# File 'lib/selenium/webdriver/firefox/features.rb', line 62 def uninstall_web_extension(extension_id) bidi? ? web_extension.uninstall(extension: extension_id) : uninstall_addon(extension_id) nil end |