Path: blob/trunk/rb/lib/selenium/webdriver/ie/options.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 IE22class Options < WebDriver::Options23KEY = 'se:ieOptions'24SCROLL_TOP = 025SCROLL_BOTTOM = 126CAPABILITIES = {27browser_attach_timeout: 'browserAttachTimeout',28element_scroll_behavior: 'elementScrollBehavior',29full_page_screenshot: 'ie.enableFullPageScreenshot',30ensure_clean_session: 'ie.ensureCleanSession',31file_upload_dialog_timeout: 'ie.fileUploadDialogTimeout',32force_create_process_api: 'ie.forceCreateProcessApi',33force_shell_windows_api: 'ie.forceShellWindowsApi',34ignore_protected_mode_settings: 'ignoreProtectedModeSettings',35ignore_zoom_level: 'ignoreZoomSetting',36initial_browser_url: 'initialBrowserUrl',37native_events: 'nativeEvents',38persistent_hover: 'enablePersistentHover',39require_window_focus: 'requireWindowFocus',40use_per_process_proxy: 'ie.usePerProcessProxy',41use_legacy_file_upload_dialog_handling: 'ie.useLegacyFileUploadDialogHandling',42attach_to_edge_chrome: 'ie.edgechromium',43edge_executable_path: 'ie.edgepath',44ignore_process_match: 'ie.ignoreprocessmatch',45silent: 'silent'46}.freeze47BROWSER = 'internet explorer'4849attr_reader :args5051#52# Create a new Options instance53#54# @example55# options = Selenium::WebDriver::IE::Options.new(args: ['--host=127.0.0.1'])56# driver = Selenium::WebDriver.for(:ie, options: options)57#58# @example59# options = Selenium::WebDriver::IE::Options.new60# options.element_scroll_behavior = Selenium::WebDriver::IE::Options::SCROLL_BOTTOM61# driver = Selenium::WebDriver.for(:ie, options: options)62#63# @param [Hash] opts the pre-defined options64# @option opts [Array<String>] args65# @option opts [Integer] browser_attach_timeout66# @option opts [Integer] element_scroll_behavior Either SCROLL_TOP or SCROLL_BOTTOM67# @option opts [Boolean] full_page_screenshot68# @option opts [Boolean] ensure_clean_session69# @option opts [Integer] file_upload_dialog_timeout70# @option opts [Boolean] force_create_process_api71# @option opts [Boolean] force_shell_windows_api72# @option opts [Boolean] ignore_protected_mode_settings73# @option opts [Boolean] ignore_zoom_level74# @option opts [String] initial_browser_url75# @option opts [Boolean] native_events76# @option opts [Boolean] persistent_hover77# @option opts [Boolean] require_window_focus78# @option opts [Boolean] use_per_process_proxy79# @option opts [Boolean] validate_cookie_document_type80#8182def initialize(**opts)83@args = (opts.delete(:args) || []).to_set84super8586@options[:native_events] = true if @options[:native_events].nil?87end8889#90# Add a command-line argument to use when starting Internet Explorer.91#92# @param [String] arg The command-line argument to add93#9495def add_argument(arg)96@args << arg97end9899private100101def process_browser_options(browser_options)102options = browser_options[KEY]103options['ie.browserCommandLineSwitches'] = @args.to_a.join(' ') if @args.any?104end105end # Options106end # IE107end # WebDriver108end # Selenium109110111