"Fossies" - the Fresh Open Source Software Archive

Member "selenium-selenium-4.8.1/rb/lib/selenium/webdriver/firefox/features.rb" (17 Feb 2023, 2250 Bytes) of package /linux/www/selenium-selenium-4.8.1.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Ruby source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. See also the last Fossies "Diffs" side-by-side code changes report for "features.rb": 4.7.0_vs_4.8.0.

    1 # frozen_string_literal: true
    2 
    3 # Licensed to the Software Freedom Conservancy (SFC) under one
    4 # or more contributor license agreements.  See the NOTICE file
    5 # distributed with this work for additional information
    6 # regarding copyright ownership.  The SFC licenses this file
    7 # to you under the Apache License, Version 2.0 (the
    8 # "License"); you may not use this file except in compliance
    9 # with the License.  You may obtain a copy of the License at
   10 #
   11 #   http://www.apache.org/licenses/LICENSE-2.0
   12 #
   13 # Unless required by applicable law or agreed to in writing,
   14 # software distributed under the License is distributed on an
   15 # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
   16 # KIND, either express or implied.  See the License for the
   17 # specific language governing permissions and limitations
   18 # under the License.
   19 
   20 module Selenium
   21   module WebDriver
   22     module Firefox
   23       module Features
   24         FIREFOX_COMMANDS = {
   25           get_context: [:get, 'session/:session_id/moz/context'],
   26           set_context: [:post, 'session/:session_id/moz/context'],
   27           install_addon: [:post, 'session/:session_id/moz/addon/install'],
   28           uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall'],
   29           full_page_screenshot: [:get, 'session/:session_id/moz/screenshot/full']
   30         }.freeze
   31 
   32         def commands(command)
   33           FIREFOX_COMMANDS[command] || self.class::COMMANDS[command]
   34         end
   35 
   36         def install_addon(path, temporary)
   37           addon = if File.directory?(path)
   38                     Zipper.zip(path)
   39                   else
   40                     File.open(path, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }
   41                   end
   42 
   43           payload = {addon: addon}
   44           payload[:temporary] = temporary unless temporary.nil?
   45           execute :install_addon, {}, payload
   46         end
   47 
   48         def uninstall_addon(id)
   49           execute :uninstall_addon, {}, {id: id}
   50         end
   51 
   52         def full_screenshot
   53           execute :full_page_screenshot
   54         end
   55 
   56         def context=(context)
   57           execute :set_context, {}, {context: context}
   58         end
   59 
   60         def context
   61           execute :get_context
   62         end
   63       end # Bridge
   64     end # Firefox
   65   end # WebDriver
   66 end # Selenium