Module: Capybara::CapybaraObscuredPatch
- Defined in:
- lib/capybara/playwright/node.rb
Constant Summary collapse
- OBSCURED_OR_OFFSET_SCRIPT =
"(el, [x, y]) => {\n var box = el.getBoundingClientRect();\n if (!x && x != 0) x = box.width/2;\n if (!y && y != 0) y = box.height/2;\n var px = box.left + x,\n py = box.top + y,\n e = document.elementFromPoint(px, py);\n if (!el.contains(e))\n return true;\n return { x: px, y: py };\n}\n"
Instance Method Summary collapse
Instance Method Details
#capybara_obscured?(x: nil, y: nil) ⇒ Boolean
49 50 51 52 53 54 55 56 57 58 |
# File 'lib/capybara/playwright/node.rb', line 49 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 |