Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
SeleniumHQ
GitHub Repository: SeleniumHQ/Selenium
Path: blob/trunk/rb/lib/selenium/webdriver/ie/options.rb
1865 views
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 IE
23
class Options < WebDriver::Options
24
KEY = 'se:ieOptions'
25
SCROLL_TOP = 0
26
SCROLL_BOTTOM = 1
27
CAPABILITIES = {
28
browser_attach_timeout: 'browserAttachTimeout',
29
element_scroll_behavior: 'elementScrollBehavior',
30
full_page_screenshot: 'ie.enableFullPageScreenshot',
31
ensure_clean_session: 'ie.ensureCleanSession',
32
file_upload_dialog_timeout: 'ie.fileUploadDialogTimeout',
33
force_create_process_api: 'ie.forceCreateProcessApi',
34
force_shell_windows_api: 'ie.forceShellWindowsApi',
35
ignore_protected_mode_settings: 'ignoreProtectedModeSettings',
36
ignore_zoom_level: 'ignoreZoomSetting',
37
initial_browser_url: 'initialBrowserUrl',
38
native_events: 'nativeEvents',
39
persistent_hover: 'enablePersistentHover',
40
require_window_focus: 'requireWindowFocus',
41
use_per_process_proxy: 'ie.usePerProcessProxy',
42
use_legacy_file_upload_dialog_handling: 'ie.useLegacyFileUploadDialogHandling',
43
attach_to_edge_chrome: 'ie.edgechromium',
44
edge_executable_path: 'ie.edgepath',
45
ignore_process_match: 'ie.ignoreprocessmatch',
46
silent: 'silent'
47
}.freeze
48
BROWSER = 'internet explorer'
49
50
attr_reader :args
51
52
#
53
# Create a new Options instance
54
#
55
# @example
56
# options = Selenium::WebDriver::IE::Options.new(args: ['--host=127.0.0.1'])
57
# driver = Selenium::WebDriver.for(:ie, options: options)
58
#
59
# @example
60
# options = Selenium::WebDriver::IE::Options.new
61
# options.element_scroll_behavior = Selenium::WebDriver::IE::Options::SCROLL_BOTTOM
62
# driver = Selenium::WebDriver.for(:ie, options: options)
63
#
64
# @param [Hash] opts the pre-defined options
65
# @option opts [Array<String>] args
66
# @option opts [Integer] browser_attach_timeout
67
# @option opts [Integer] element_scroll_behavior Either SCROLL_TOP or SCROLL_BOTTOM
68
# @option opts [Boolean] full_page_screenshot
69
# @option opts [Boolean] ensure_clean_session
70
# @option opts [Integer] file_upload_dialog_timeout
71
# @option opts [Boolean] force_create_process_api
72
# @option opts [Boolean] force_shell_windows_api
73
# @option opts [Boolean] ignore_protected_mode_settings
74
# @option opts [Boolean] ignore_zoom_level
75
# @option opts [String] initial_browser_url
76
# @option opts [Boolean] native_events
77
# @option opts [Boolean] persistent_hover
78
# @option opts [Boolean] require_window_focus
79
# @option opts [Boolean] use_per_process_proxy
80
# @option opts [Boolean] validate_cookie_document_type
81
#
82
83
def initialize(**opts)
84
@args = (opts.delete(:args) || []).to_set
85
super
86
87
@options[:native_events] = true if @options[:native_events].nil?
88
end
89
90
#
91
# Add a command-line argument to use when starting Internet Explorer.
92
#
93
# @param [String] arg The command-line argument to add
94
#
95
96
def add_argument(arg)
97
@args << arg
98
end
99
100
private
101
102
def process_browser_options(browser_options)
103
options = browser_options[KEY]
104
options['ie.browserCommandLineSwitches'] = @args.to_a.join(' ') if @args.any?
105
end
106
end # Options
107
end # IE
108
end # WebDriver
109
end # Selenium
110
111