Path: blob/trunk/rb/lib/selenium/webdriver/firefox/features.rb
1865 views
# frozen_string_literal: true12# Licensed to the Software Freedom Conservancy (SFC) under one3# or more contributor license agreements. See the NOTICE file4# distributed with this work for additional information5# regarding copyright ownership. The SFC licenses this file6# to you under the Apache License, Version 2.0 (the7# "License"); you may not use this file except in compliance8# with the License. You may obtain a copy of the License at9#10# http://www.apache.org/licenses/LICENSE-2.011#12# Unless required by applicable law or agreed to in writing,13# software distributed under the License is distributed on an14# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY15# KIND, either express or implied. See the License for the16# specific language governing permissions and limitations17# under the License.1819module Selenium20module WebDriver21module Firefox22module Features23FIREFOX_COMMANDS = {24get_context: [:get, 'session/:session_id/moz/context'],25set_context: [:post, 'session/:session_id/moz/context'],26install_addon: [:post, 'session/:session_id/moz/addon/install'],27uninstall_addon: [:post, 'session/:session_id/moz/addon/uninstall'],28full_page_screenshot: [:get, 'session/:session_id/moz/screenshot/full']29}.freeze3031def command_list32FIREFOX_COMMANDS.merge(self.class::COMMANDS)33end3435def commands(command)36command_list[command]37end3839def install_addon(path, temporary)40addon = if File.directory?(path)41Zipper.zip(path)42else43File.open(path, 'rb') { |crx_file| Base64.strict_encode64 crx_file.read }44end4546payload = {addon: addon}47payload[:temporary] = temporary unless temporary.nil?48execute :install_addon, {}, payload49end5051def uninstall_addon(id)52execute :uninstall_addon, {}, {id: id}53end5455def full_screenshot56execute :full_page_screenshot57end5859def context=(context)60execute :set_context, {}, {context: context}61end6263def context64execute :get_context65end66end # Bridge67end # Firefox68end # WebDriver69end # Selenium707172