Class: Capybara::Playwright::ShadowRootNode
- Inherits:
-
Node
- Object
- Driver::Node
- Node
- Capybara::Playwright::ShadowRootNode
show all
- Defined in:
- lib/capybara/playwright/shadow_root_node.rb
Constant Summary
Constants inherited
from Node
Node::SCROLL_POSITIONS
Instance Method Summary
collapse
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, internal_logger, page, element) ⇒ ShadowRootNode
6
7
8
9
|
# File 'lib/capybara/playwright/shadow_root_node.rb', line 6
def initialize(driver, internal_logger, 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?
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
|