Class: Playwright::ChannelOwners::ElementHandle
- Inherits:
-
JSHandle
- Object
- PlaywrightApi
- JSHandle
- Playwright::ChannelOwners::ElementHandle
- Defined in:
- lib/playwright/channel_owners/element_handle.rb
Instance Method Summary collapse
- #as_element ⇒ Object
- #bounding_box ⇒ Object
- #check(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
- #checked? ⇒ Boolean
- #click(button: nil, clickCount: nil, delay: nil, force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
- #content_frame ⇒ Object
- #dblclick(button: nil, delay: nil, force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
- #disabled? ⇒ Boolean
- #dispatch_event(type, eventInit: nil) ⇒ Object
- #editable? ⇒ Boolean
- #enabled? ⇒ Boolean
- #eval_on_selector(selector, pageFunction, arg: nil) ⇒ Object
- #eval_on_selector_all(selector, pageFunction, arg: nil) ⇒ Object
- #fill(value, force: nil, noWaitAfter: nil, timeout: nil) ⇒ Object
- #focus ⇒ Object
- #get_attribute(name) ⇒ Object
- #hidden? ⇒ Boolean
- #hover(force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
- #inner_html ⇒ Object
- #inner_text ⇒ Object
- #input_value(timeout: nil) ⇒ Object
- #owner_frame ⇒ Object
- #press(key, delay: nil, noWaitAfter: nil, timeout: nil) ⇒ Object
- #query_selector(selector) ⇒ Object
- #query_selector_all(selector) ⇒ Object
- #screenshot(animations: nil, caret: nil, mask: nil, maskColor: nil, omitBackground: nil, path: nil, quality: nil, scale: nil, timeout: nil, type: nil) ⇒ Object
- #scroll_into_view_if_needed(timeout: nil) ⇒ Object
- #select_option(element: nil, index: nil, value: nil, label: nil, force: nil, noWaitAfter: nil, timeout: nil) ⇒ Object
- #select_text(force: nil, timeout: nil) ⇒ Object
- #set_checked(checked, **options) ⇒ Object
- #set_input_files(files, noWaitAfter: nil, timeout: nil) ⇒ Object
- #tap_point(force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
- #text_content ⇒ Object
- #type(text, delay: nil, noWaitAfter: nil, timeout: nil) ⇒ Object
- #uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
- #visible? ⇒ Boolean
- #wait_for_element_state(state, timeout: nil) ⇒ Object
- #wait_for_selector(selector, state: nil, strict: nil, timeout: nil) ⇒ Object
Methods inherited from JSHandle
#dispose, #evaluate, #evaluate_handle, #get_properties, #get_property, #json_value, #off, #on, #once, #to_s
Methods inherited from PlaywrightApi
Constructor Details
This class inherits a constructor from Playwright::PlaywrightApi
Instance Method Details
#as_element ⇒ Object
6 7 8 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 6 def as_element self end |
#bounding_box ⇒ Object
291 292 293 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 291 def bounding_box @channel.('boundingBox') end |
#check(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
257 258 259 260 261 262 263 264 265 266 267 268 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 257 def check(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) params = { force: force, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial, }.compact @channel.('check', params) nil end |
#checked? ⇒ Boolean
36 37 38 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 36 def checked? @channel.('isChecked') end |
#click(button: nil, clickCount: nil, delay: nil, force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 99 def click( button: nil, clickCount: nil, delay: nil, force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) params = { button: , clickCount: clickCount, delay: delay, force: force, modifiers: modifiers, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial, }.compact @channel.('click', params) nil end |
#content_frame ⇒ Object
15 16 17 18 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 15 def content_frame resp = @channel.('contentFrame') ChannelOwners::Frame.from_nullable(resp) end |
#dblclick(button: nil, delay: nil, force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 126 def dblclick( button: nil, delay: nil, force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) params = { button: , delay: delay, force: force, modifiers: modifiers, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial, }.compact @channel.('dblclick', params) nil end |
#disabled? ⇒ Boolean
40 41 42 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 40 def disabled? @channel.('isDisabled') end |
#dispatch_event(type, eventInit: nil) ⇒ Object
60 61 62 63 64 65 66 67 68 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 60 def dispatch_event(type, eventInit: nil) params = { type: type, eventInit: JavaScript::ValueSerializer.new(eventInit).serialize, }.compact @channel.('dispatchEvent', params) nil end |
#editable? ⇒ Boolean
44 45 46 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 44 def editable? @channel.('isEditable') end |
#enabled? ⇒ Boolean
48 49 50 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 48 def enabled? @channel.('isEnabled') end |
#eval_on_selector(selector, pageFunction, arg: nil) ⇒ Object
344 345 346 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 344 def eval_on_selector(selector, pageFunction, arg: nil) JavaScript::Expression.new(pageFunction, arg).eval_on_selector(@channel, selector) end |
#eval_on_selector_all(selector, pageFunction, arg: nil) ⇒ Object
348 349 350 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 348 def eval_on_selector_all(selector, pageFunction, arg: nil) JavaScript::Expression.new(pageFunction, arg).eval_on_selector_all(@channel, selector) end |
#fill(value, force: nil, noWaitAfter: nil, timeout: nil) ⇒ Object
190 191 192 193 194 195 196 197 198 199 200 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 190 def fill(value, force: nil, noWaitAfter: nil, timeout: nil) params = { value: value, force: force, noWaitAfter: noWaitAfter, timeout: timeout, }.compact @channel.('fill', params) nil end |
#focus ⇒ Object
227 228 229 230 231 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 227 def focus @channel.('focus') nil end |
#get_attribute(name) ⇒ Object
20 21 22 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 20 def get_attribute(name) @channel.('getAttribute', name: name) end |
#hidden? ⇒ Boolean
52 53 54 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 52 def hidden? @channel.('isHidden') end |
#hover(force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 79 def hover( force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) params = { force: force, modifiers: modifiers, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial, }.compact @channel.('hover', params) nil end |
#inner_html ⇒ Object
32 33 34 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 32 def inner_html @channel.('innerHTML') end |
#inner_text ⇒ Object
28 29 30 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 28 def inner_text @channel.('innerText') end |
#input_value(timeout: nil) ⇒ Object
209 210 211 212 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 209 def input_value(timeout: nil) params = { timeout: timeout }.compact @channel.('inputValue', params) end |
#owner_frame ⇒ Object
10 11 12 13 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 10 def owner_frame resp = @channel.('ownerFrame') ChannelOwners::Frame.from_nullable(resp) end |
#press(key, delay: nil, noWaitAfter: nil, timeout: nil) ⇒ Object
245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 245 def press(key, delay: nil, noWaitAfter: nil, timeout: nil) params = { key: key, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout, }.compact @channel.('press', params) nil end |
#query_selector(selector) ⇒ Object
333 334 335 336 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 333 def query_selector(selector) resp = @channel.('querySelector', selector: selector) ChannelOwners::ElementHandle.from_nullable(resp) end |
#query_selector_all(selector) ⇒ Object
338 339 340 341 342 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 338 def query_selector_all(selector) @channel.('querySelectorAll', selector: selector).map do |el| ChannelOwners::ElementHandle.from(el) end end |
#screenshot(animations: nil, caret: nil, mask: nil, maskColor: nil, omitBackground: nil, path: nil, quality: nil, scale: nil, timeout: nil, type: nil) ⇒ Object
295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 295 def screenshot( animations: nil, caret: nil, mask: nil, maskColor: nil, omitBackground: nil, path: nil, quality: nil, scale: nil, timeout: nil, type: nil) params = { animations: animations, caret: caret, maskColor: maskColor, omitBackground: omitBackground, path: path, quality: quality, scale: scale, timeout: timeout, type: type, }.compact if mask.is_a?(Enumerable) params[:mask] = mask.map do |locator| locator.send(:to_protocol) end end encoded_binary = @channel.('screenshot', params) decoded_binary = Base64.strict_decode64(encoded_binary) if path File.open(path, 'wb') do |f| f.write(decoded_binary) end end decoded_binary end |
#scroll_into_view_if_needed(timeout: nil) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 70 def scroll_into_view_if_needed(timeout: nil) params = { timeout: timeout, }.compact @channel.('scrollIntoViewIfNeeded', params) nil end |
#select_option(element: nil, index: nil, value: nil, label: nil, force: nil, noWaitAfter: nil, timeout: nil) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 151 def select_option( element: nil, index: nil, value: nil, label: nil, force: nil, noWaitAfter: nil, timeout: nil) base_params = SelectOptionValues.new( element: element, index: index, value: value, label: label, ).as_params params = base_params.merge({ force: force, noWaitAfter: noWaitAfter, timeout: timeout }.compact) @channel.('selectOption', params) end |
#select_text(force: nil, timeout: nil) ⇒ Object
202 203 204 205 206 207 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 202 def select_text(force: nil, timeout: nil) params = { force: force, timeout: timeout }.compact @channel.('selectText', params) nil end |
#set_checked(checked, **options) ⇒ Object
283 284 285 286 287 288 289 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 283 def set_checked(checked, **) if checked check(**) else uncheck(**) end end |
#set_input_files(files, noWaitAfter: nil, timeout: nil) ⇒ Object
214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 214 def set_input_files(files, noWaitAfter: nil, timeout: nil) frame = owner_frame unless frame raise 'Cannot set input files to detached element' end method_name, params = InputFiles.new(frame.page.context, files).as_method_and_params params.merge!({ noWaitAfter: noWaitAfter, timeout: timeout }.compact) @channel.(method_name, params) nil end |
#tap_point(force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 169 def tap_point( force: nil, modifiers: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) params = { force: force, modifiers: modifiers, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial, }.compact @channel.('tap', params) nil end |
#text_content ⇒ Object
24 25 26 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 24 def text_content @channel.('textContent') end |
#type(text, delay: nil, noWaitAfter: nil, timeout: nil) ⇒ Object
233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 233 def type(text, delay: nil, noWaitAfter: nil, timeout: nil) params = { text: text, delay: delay, noWaitAfter: noWaitAfter, timeout: timeout, }.compact @channel.('type', params) nil end |
#uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) ⇒ Object
270 271 272 273 274 275 276 277 278 279 280 281 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 270 def uncheck(force: nil, noWaitAfter: nil, position: nil, timeout: nil, trial: nil) params = { force: force, noWaitAfter: noWaitAfter, position: position, timeout: timeout, trial: trial, }.compact @channel.('uncheck', params) nil end |
#visible? ⇒ Boolean
56 57 58 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 56 def visible? @channel.('isVisible') end |
#wait_for_element_state(state, timeout: nil) ⇒ Object
352 353 354 355 356 357 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 352 def wait_for_element_state(state, timeout: nil) params = { state: state, timeout: timeout }.compact @channel.('waitForElementState', params) nil end |
#wait_for_selector(selector, state: nil, strict: nil, timeout: nil) ⇒ Object
359 360 361 362 363 364 |
# File 'lib/playwright/channel_owners/element_handle.rb', line 359 def wait_for_selector(selector, state: nil, strict: nil, timeout: nil) params = { selector: selector, state: state, strict: strict, timeout: timeout }.compact resp = @channel.('waitForSelector', params) ChannelOwners::ElementHandle.from_nullable(resp) end |