Class: Pincers::Chenso::Backend
Constant Summary
Nokogiri::Backend::BOOL_PROPERTIES
Instance Attribute Summary collapse
Instance Method Summary
collapse
#close_document, #document_root, #document_title, #extract_element_attribute, #extract_element_html, #extract_element_tag, #extract_element_text, #search_by_css, #search_by_xpath, #set_element_attribute
#clear_input, #close_document, #document_root, #document_title, #double_click_on_element, #drag_and_drop, #element_is_actionable?, #elements_equal, #extract_element_attribute, #extract_element_html, #extract_element_tag, #extract_element_text, #fetch_cookies, #fetch_resource, #hover_over_element, #javascript_enabled?, #right_click_on_element, #search_by_css, #search_by_xpath, #set_element_attribute, #switch_to_parent_frame
Constructor Details
#initialize(_http_client) ⇒ Backend
Returns a new instance of Backend.
13
14
15
16
17
|
# File 'lib/pincers/chenso/backend.rb', line 13
def initialize(_http_client)
super nil
@client = _http_client
@browser = BrowsingManager.new @client
end
|
Instance Attribute Details
#browser ⇒ Object
Returns the value of attribute browser.
11
12
13
|
# File 'lib/pincers/chenso/backend.rb', line 11
def browser
@browser
end
|
#client ⇒ Object
Returns the value of attribute client.
11
12
13
|
# File 'lib/pincers/chenso/backend.rb', line 11
def client
@client
end
|
Instance Method Details
#as_http_client ⇒ Object
71
72
73
|
# File 'lib/pincers/chenso/backend.rb', line 71
def as_http_client
@client.fork(true)
end
|
#click_on_element(_element, _modifiers) ⇒ Object
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
# File 'lib/pincers/chenso/backend.rb', line 51
def click_on_element(_element, _modifiers)
case classify _element
when :a
navigate_link _element
when :option
select_option _element
when :input_checkbox
toggle_checkbox _element
when :input_radio
set_radio_button _element
when :input_submit, :button_submit, :button
submit_parent_form _element
end
end
|
#document ⇒ Object
19
20
21
|
# File 'lib/pincers/chenso/backend.rb', line 19
def document
browser.document
end
|
#document_url ⇒ Object
23
24
25
|
# File 'lib/pincers/chenso/backend.rb', line 23
def document_url
browser.current_url
end
|
#merge_http_client(_client) ⇒ Object
75
76
77
78
79
80
|
# File 'lib/pincers/chenso/backend.rb', line 75
def merge_http_client(_client)
@client.join _client
if _client.content and /text\/html/ === _client.content_type
@browser.push HtmlPageCache.new(_client.uri, _client.content)
end
end
|
#navigate_back(_steps) ⇒ Object
35
36
37
|
# File 'lib/pincers/chenso/backend.rb', line 35
def navigate_back(_steps)
browser.back _steps
end
|
#navigate_forward(_steps) ⇒ Object
31
32
33
|
# File 'lib/pincers/chenso/backend.rb', line 31
def navigate_forward(_steps)
browser.forward _steps
end
|
#navigate_to(_url) ⇒ Object
27
28
29
|
# File 'lib/pincers/chenso/backend.rb', line 27
def navigate_to(_url)
browser.push new_page_request _url
end
|
#refresh_document ⇒ Object
39
40
41
|
# File 'lib/pincers/chenso/backend.rb', line 39
def refresh_document
browser.refresh
end
|
#set_element_text(_element, _value) ⇒ Object
43
44
45
46
47
48
49
|
# File 'lib/pincers/chenso/backend.rb', line 43
def set_element_text(_element, _value)
case classify _element
when :input_text, :input_password, :input_email, :input_number, :textarea
set_att _element, :value, _value
end
end
|
66
67
68
69
|
# File 'lib/pincers/chenso/backend.rb', line 66
def submit_form(_element)
form = new_form _element
load_in_target form_as_request(form), form.target
end
|
#switch_to_frame(_element) ⇒ Object
82
83
84
85
86
|
# File 'lib/pincers/chenso/backend.rb', line 82
def switch_to_frame(_element)
if _element[:src] && !browser.switch_frame(_element[:src])
browser.load_frame(_element[:src], new_page_request(_element[:src]))
end
end
|
#switch_to_top_frame ⇒ Object
88
89
90
|
# File 'lib/pincers/chenso/backend.rb', line 88
def switch_to_top_frame
browser.switch_top_frame
end
|