Module: Prickle::Capybara
- Defined in:
- lib/prickle/capybara.rb,
lib/prickle/capybara/actions.rb,
lib/prickle/capybara/element.rb
Defined Under Namespace
Modules: Actions
Classes: Element
Class Attribute Summary collapse
Instance Method Summary
collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args) ⇒ Object
49
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/prickle/capybara.rb', line 49
def method_missing method, *args
if method =~ /(^.*)_contains_text\?$/
element($1, :name => args.first).contains_text? args[1]
elsif method =~ /^click_(.*)_by_name$/
element($1, :name => args.first).click
elsif method =~ /^find_(.*)_by_name$/
element($1, :name => args.first).exists?
else
super
end
end
|
Class Attribute Details
.image_dir ⇒ Object
Returns the value of attribute image_dir.
9
10
11
|
# File 'lib/prickle/capybara.rb', line 9
def image_dir
@image_dir
end
|
.wait_time ⇒ Object
Returns the value of attribute wait_time.
9
10
11
|
# File 'lib/prickle/capybara.rb', line 9
def wait_time
@wait_time
end
|
Instance Method Details
#capture_screen(name = screenshot_name) ⇒ Object
13
14
15
|
# File 'lib/prickle/capybara.rb', line 13
def capture_screen name=screenshot_name
page.driver.browser.save_screenshot Capybara.image_dir + name + ".jpg"
end
|
#click_by_name(name) ⇒ Object
17
18
19
|
# File 'lib/prickle/capybara.rb', line 17
def click_by_name name
find_by_name(name).click
end
|
21
22
23
|
# File 'lib/prickle/capybara.rb', line 21
def
page.driver.browser.switch_to.alert.accept
end
|
25
26
27
|
# File 'lib/prickle/capybara.rb', line 25
def
page.driver.browser.switch_to.alert.dismiss
end
|
#element(type = Element::OF_ANY_TYPE, identifier) ⇒ Object
29
30
31
|
# File 'lib/prickle/capybara.rb', line 29
def element type=Element::OF_ANY_TYPE, identifier
Element.new type, identifier
end
|
#find_by_name(type = Element::OF_ANY_TYPE, name) ⇒ Object
33
34
35
|
# File 'lib/prickle/capybara.rb', line 33
def find_by_name type=Element::OF_ANY_TYPE, name
element(type, :name => name).exists?
end
|
37
38
39
|
# File 'lib/prickle/capybara.rb', line 37
def
page.driver.browser.switch_to.alert.text
end
|