Class: Capybara::Playwright::ShadowRootNode
- Defined in:
- lib/capybara/playwright/shadow_root_node.rb
Constant Summary
Constants inherited from Node
Instance Method Summary collapse
- #all_text ⇒ Object
-
#initialize(driver, page, element) ⇒ ShadowRootNode
constructor
A new instance of ShadowRootNode.
- #visible_text ⇒ Object
Methods inherited from Node
#==, #[], #checked?, #click, #disabled?, #double_click, #drag_to, #drop, #find_css, #find_xpath, #hover, #inspect, #multiple?, #obscured?, #path, #readonly?, #rect, #right_click, #scroll_by, #scroll_to, #select_option, #selected?, #send_keys, #set, #shadow_root, #style, #tag_name, #trigger, #unselect_option, #value, #visible?
Constructor Details
#initialize(driver, page, element) ⇒ ShadowRootNode
Returns a new instance of ShadowRootNode.
6 7 8 9 |
# File 'lib/capybara/playwright/shadow_root_node.rb', line 6 def initialize(driver, page, element) super @shadow_roow_element = element.evaluate_handle('el => el.shadowRoot') end |
Instance Method Details
#all_text ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/capybara/playwright/shadow_root_node.rb', line 11 def all_text assert_element_not_stale { text = @shadow_roow_element.text_content text.to_s.gsub(/[\u200b\u200e\u200f]/, '') .gsub(/[\ \n\f\t\v\u2028\u2029]+/, ' ') .gsub(/\A[[:space:]&&[^\u00a0]]+/, '') .gsub(/[[:space:]&&[^\u00a0]]+\z/, '') .tr("\u00a0", ' ') } end |
#visible_text ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/capybara/playwright/shadow_root_node.rb', line 22 def visible_text assert_element_not_stale { return '' unless visible? # https://github.com/teamcapybara/capybara/blob/1c164b608fa6452418ec13795b293655f8a0102a/lib/capybara/rack_test/node.rb#L18 displayed_text = @shadow_roow_element.text_content.to_s. gsub(/[\u200b\u200e\u200f]/, ''). gsub(/[\ \n\f\t\v\u2028\u2029]+/, ' ') displayed_text.squeeze(' ') .gsub(/[\ \n]*\n[\ \n]*/, "\n") .gsub(/\A[[:space:]&&[^\u00a0]]+/, '') .gsub(/[[:space:]&&[^\u00a0]]+\z/, '') .tr("\u00a0", ' ') } end |