Module: Capybara::Playwright::Node::UpdateValueJS
- Included in:
- DateInput, DateTimeInput, JSValueInput, TimeInput
- Defined in:
- lib/capybara/playwright/node.rb
Instance Method Summary collapse
Instance Method Details
#update_value_js(element, value) ⇒ Object
271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/capybara/playwright/node.rb', line 271 def update_value_js(element, value) # ref: https://github.com/teamcapybara/capybara/blob/f7ab0b5cd5da86185816c2d5c30d58145fe654ed/lib/capybara/selenium/node.rb#L343 js = <<~JAVASCRIPT (el, value) => { if (el.readOnly) { return }; if (document.activeElement !== el){ el.focus(); } if (el.value != value) { el.value = value; el.dispatchEvent(new InputEvent('input')); el.dispatchEvent(new Event('change', { bubbles: true })); } } JAVASCRIPT element.evaluate(js, arg: value) end |