Class: OperaWatir::Browser
- Includes:
- Deprecated
- Defined in:
- lib/operawatir/browser.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#active_window ⇒ Object
(also: #window)
Returns the value of attribute active_window.
-
#driver ⇒ Object
Returns the value of attribute driver.
-
#keys ⇒ Object
Returns the value of attribute keys.
-
#preferences ⇒ Object
Returns the value of attribute preferences.
-
#spatnav ⇒ Object
Returns the value of attribute spatnav.
-
#utils ⇒ Object
Returns the value of attribute utils.
Class Method Summary collapse
Instance Method Summary collapse
-
#actions ⇒ Object
actions.
-
#copy ⇒ Object
Copies the currently selected content to the clipboard.
-
#cut ⇒ Object
Cuts the currently selected content to the clipboard.
-
#desktop? ⇒ Boolean
Is attached browser instance of type internal build or public desktop?.
-
#initialize ⇒ Object
constructor
Constructs a new OperaDriver::Browser object.
-
#key(key) ⇒ Object
Keyboard.
- #key_down(key) ⇒ Object
- #key_up(key) ⇒ Object
-
#name ⇒ String
Get the name of the browser currently being run.
-
#opera_action(name, *args) ⇒ String
Sends an Opera action to the browser.
-
#opera_action_list ⇒ String
Full list of available Opera actions in the Opera build you’re using.
-
#paste ⇒ Object
Pastes content from the clipboard into the currently focused element.
-
#path ⇒ String
Get the full path to the attached browser binary.
-
#platform ⇒ String
Get the target device’s platform.
-
#quit ⇒ Object
Instruct the browser instance to quit and shut down.
-
#select_all ⇒ Object
Selects all content in the currently focused element.
- #type(text) ⇒ Object
-
#ua_string ⇒ String
Fetches the user agent (UA) string the browser currently uses.
-
#url=(url) ⇒ Object
Navigate to a new URL and return a Window object.
-
#version ⇒ String
Get the version number of the driver.
Constructor Details
#initialize ⇒ Object
Constructs a new OperaDriver::Browser object.
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/operawatir/browser.rb', line 22 def initialize OperaWatir.compatibility! unless OperaWatir.api >= 3 self.driver = OperaDriver.new(self.class.desired_capabilities) self.active_window = OperaWatir::Window.new(self) self.preferences = OperaWatir::Preferences.new(self) self.keys = OperaWatir::Keys.new(self) self.spatnav = OperaWatir::Spatnav.new(self) self.utils = OperaWatir::Utils.new(self) end |
Instance Attribute Details
#active_window ⇒ Object Also known as: window
Returns the value of attribute active_window.
5 6 7 |
# File 'lib/operawatir/browser.rb', line 5 def active_window @active_window end |
#driver ⇒ Object
Returns the value of attribute driver.
5 6 7 |
# File 'lib/operawatir/browser.rb', line 5 def driver @driver end |
#keys ⇒ Object
Returns the value of attribute keys.
5 6 7 |
# File 'lib/operawatir/browser.rb', line 5 def keys @keys end |
#preferences ⇒ Object
Returns the value of attribute preferences.
5 6 7 |
# File 'lib/operawatir/browser.rb', line 5 def preferences @preferences end |
#spatnav ⇒ Object
Returns the value of attribute spatnav.
5 6 7 |
# File 'lib/operawatir/browser.rb', line 5 def spatnav @spatnav end |
#utils ⇒ Object
Returns the value of attribute utils.
5 6 7 |
# File 'lib/operawatir/browser.rb', line 5 def utils @utils end |
Class Method Details
.settings ⇒ Object
12 13 14 |
# File 'lib/operawatir/browser.rb', line 12 def self.settings @settings || self.settings = {} end |
.settings=(settings = {}) ⇒ Object
7 8 9 10 |
# File 'lib/operawatir/browser.rb', line 7 def self.settings=(settings={}) @desired_capabilities = nil # Bust cache @settings = settings end |
Instance Method Details
#actions ⇒ Object
actions
196 197 198 |
# File 'lib/operawatir/browser.rb', line 196 def actions OperaWatir::Actions.new(browser) end |
#copy ⇒ Object
Copies the currently selected content to the clipboard. Equivalent to pressing C-c in a desktop browser.
129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/operawatir/browser.rb', line 129 def copy # FIXME: #copy, #cut and #paste really shouldn't use platform- # dependent keypresses like this. But until DSK-327491 is fixed, # this will have to do. if OperaWatir::Platform.os == :macosx keys.send [:command, 'c'] else keys.send [:control, 'c'] end end |
#cut ⇒ Object
Cuts the currently selected content to the clipboard. Equivalent to pressing C-x in a desktop browser.
143 144 145 146 147 148 149 150 151 |
# File 'lib/operawatir/browser.rb', line 143 def cut # FIXME if OperaWatir::Platform.os == :macosx keys.send [:command, 'x'] else keys.send [:control, 'x'] end end |
#desktop? ⇒ Boolean
Is attached browser instance of type internal build or public desktop?
92 93 94 |
# File 'lib/operawatir/browser.rb', line 92 def desktop? false # FIXME end |
#key(key) ⇒ Object
Keyboard
170 171 172 |
# File 'lib/operawatir/browser.rb', line 170 def key(key) driver.key(key) end |
#key_down(key) ⇒ Object
176 177 178 |
# File 'lib/operawatir/browser.rb', line 176 def key_down(key) driver.keyDown(key) end |
#key_up(key) ⇒ Object
182 183 184 |
# File 'lib/operawatir/browser.rb', line 182 def key_up(key) driver.keyUp(key) end |
#name ⇒ String
Get the name of the browser currently being run.
38 39 40 |
# File 'lib/operawatir/browser.rb', line 38 def name 'Opera' end |
#opera_action(name, *args) ⇒ String
Sends an Opera action to the browser.
100 101 102 |
# File 'lib/operawatir/browser.rb', line 100 def opera_action(name, *args) driver.operaAction(name, args.to_java(:string)) end |
#opera_action_list ⇒ String
Full list of available Opera actions in the Opera build you’re using. Note that this list varies from configuration to configuration, and from build to build. The Opera actions available to devices-type builds will vary greatly from those available to desktop-types.
113 114 115 |
# File 'lib/operawatir/browser.rb', line 113 def opera_action_list driver.getOperaActionList.to_a end |
#paste ⇒ Object
Pastes content from the clipboard into the currently focused element. Equivalent to pressing C-v in a desktop browser. To paste content into textarea or input fields, remember to click it first.
157 158 159 160 161 162 163 164 165 |
# File 'lib/operawatir/browser.rb', line 157 def paste # FIXME if OperaWatir::Platform.os == :macosx keys.send [:command, 'v'] else keys.send [:control, 'v'] end end |
#path ⇒ String
Get the full path to the attached browser binary.
76 77 78 |
# File 'lib/operawatir/browser.rb', line 76 def path driver.getPath end |
#platform ⇒ String
Get the target device’s platform. This is not equivalent of the platform the OperaWatir server might be running on.
69 70 71 |
# File 'lib/operawatir/browser.rb', line 69 def platform window.execute_script('navigator.platform') end |
#quit ⇒ Object
Instruct the browser instance to quit and shut down.
51 52 53 |
# File 'lib/operawatir/browser.rb', line 51 def quit driver.quit end |
#select_all ⇒ Object
Selects all content in the currently focused element. Equivalent to pressing C-a in a desktop browser. To select content in a <textarea> or an <input> field, remember to click it first.
122 123 124 125 |
# File 'lib/operawatir/browser.rb', line 122 def select_all # FIXME driver.operaAction('Select all') end |
#type(text) ⇒ Object
188 189 190 |
# File 'lib/operawatir/browser.rb', line 188 def type(text) driver.type(text) end |
#ua_string ⇒ String
Fetches the user agent (UA) string the browser currently uses.
83 84 85 |
# File 'lib/operawatir/browser.rb', line 83 def ua_string window.execute_script('navigator.userAgent') end |
#url=(url) ⇒ Object
Navigate to a new URL and return a Window object.
46 47 48 |
# File 'lib/operawatir/browser.rb', line 46 def url=(url) active_window.url = url end |
#version ⇒ String
Get the version number of the driver. This _is not_ the same as the version number for OperaWatir, which can be retrieved using OperaWatir.version instead.
60 61 62 |
# File 'lib/operawatir/browser.rb', line 60 def version driver.getVersion end |