Module: Capybara::CapybaraObscuredPatch
- Defined in:
- lib/capybara/playwright/node.rb
Constant Summary collapse
- OBSCURED_OR_OFFSET_SCRIPT =
<<~JAVASCRIPT (el, [x, y]) => { var box = el.getBoundingClientRect(); if (!x && x != 0) x = box.width/2; if (!y && y != 0) y = box.height/2; var px = box.left + x, py = box.top + y, e = document.elementFromPoint(px, py); if (!el.contains(e)) return true; return { x: px, y: py }; } JAVASCRIPT
Instance Method Summary collapse
Instance Method Details
#capybara_obscured?(x: nil, y: nil) ⇒ Boolean
46 47 48 49 50 51 52 53 54 55 |
# File 'lib/capybara/playwright/node.rb', line 46 def (x: nil, y: nil) res = evaluate(OBSCURED_OR_OFFSET_SCRIPT, arg: [x, y]) return true if res == true # ref: https://github.com/teamcapybara/capybara/blob/f7ab0b5cd5da86185816c2d5c30d58145fe654ed/lib/capybara/selenium/driver.rb#L182 frame = owner_frame return false unless frame.parent_frame frame.frame_element.(x: res['x'], y: res['y']) end |