Class: Pincers::Nokogiri::Backend
Constant Summary
collapse
- BOOL_PROPERTIES =
{
checked: [:input_checkbox, :input_radio],
selected: [:option],
disabled: :all, readonly: [:input_text, :input_password, :textarea],
multiple: [:select]
}
Instance Method Summary
collapse
#as_http_client, #clear_input, #click_on_element, #document_url, #double_click_on_element, #drag_and_drop, #element_is_actionable?, #elements_equal, #fetch_cookies, #fetch_resource, #hover_over_element, #javascript_enabled?, #merge_http_client, #navigate_back, #navigate_forward, #navigate_to, #refresh_document, #right_click_on_element, #set_element_text, #submit_form, #switch_to_frame, #switch_to_parent_frame, #switch_to_top_frame
Constructor Details
#initialize(_document) ⇒ Backend
Returns a new instance of Backend.
17
18
19
|
# File 'lib/pincers/nokogiri/backend.rb', line 17
def initialize(_document)
@document = _document
end
|
Instance Method Details
#close_document ⇒ Object
33
34
35
|
# File 'lib/pincers/nokogiri/backend.rb', line 33
def close_document
end
|
#document ⇒ Object
21
22
23
|
# File 'lib/pincers/nokogiri/backend.rb', line 21
def document
@document
end
|
#document_root ⇒ Object
25
26
27
|
# File 'lib/pincers/nokogiri/backend.rb', line 25
def document_root
[document]
end
|
#document_title ⇒ Object
29
30
31
|
# File 'lib/pincers/nokogiri/backend.rb', line 29
def document_title
document.title
end
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/pincers/nokogiri/backend.rb', line 59
def (_element, _name)
_name = _name.to_sym
if _name == :value
case classify _element
when :input_checkbox, :input_radio
_element
when :select
_element
when :option
_element
when :textarea
_element.content
else
_element[:value]
end
elsif is_boolean? _element, _name
!_element[_name].nil?
else
_element[_name]
end
end
|
55
56
57
|
# File 'lib/pincers/nokogiri/backend.rb', line 55
def (_element)
_element.to_html
end
|
47
48
49
|
# File 'lib/pincers/nokogiri/backend.rb', line 47
def (_element)
_element.name
end
|
51
52
53
|
# File 'lib/pincers/nokogiri/backend.rb', line 51
def (_element)
_element.content
end
|
#search_by_css(_element, _selector, _limit) ⇒ Object
37
38
39
40
|
# File 'lib/pincers/nokogiri/backend.rb', line 37
def search_by_css(_element, _selector, _limit)
_element.css _selector
end
|
#search_by_xpath(_element, _selector, _limit) ⇒ Object
42
43
44
45
|
# File 'lib/pincers/nokogiri/backend.rb', line 42
def search_by_xpath(_element, _selector, _limit)
_element.xpath _selector
end
|
#set_element_attribute(_element, _name, _value) ⇒ Object
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
|
# File 'lib/pincers/nokogiri/backend.rb', line 81
def set_element_attribute(_element, _name, _value)
_name = _name.to_sym
if _name == :value
case classify _element
when :select
set_select_value _element, _value
when :textarea
_element.content = _value
else
_element.set_attribute(_name, _value)
end
elsif is_boolean? _element, _name
set_boolean _element, _name, _value
else
_element.set_attribute(_name, _value)
end
end
|