druid-ts 0.0.1 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/.rspec +1 -0
- data/.rvmrc +1 -0
- data/.travis.yml +1 -2
- data/ChangeLog +218 -0
- data/Gemfile +2 -1
- data/README.md +64 -7
- data/Rakefile +1 -1
- data/druid.gemspec +25 -0
- data/features/async.feature +18 -0
- data/features/button.feature +42 -1
- data/features/checkbox.feature +7 -1
- data/features/div.feature +6 -0
- data/features/element.feature +100 -0
- data/features/file_field.feature +35 -0
- data/features/form.feature +12 -6
- data/features/frames.feature +57 -0
- data/features/heading.feature +164 -0
- data/features/hidden_field.feature +6 -0
- data/features/html/async.html +18 -0
- data/features/html/frame_1.html +18 -0
- data/features/html/frame_2.html +16 -0
- data/features/html/frame_3.html +14 -0
- data/features/html/frames.html +12 -0
- data/features/html/iframes.html +12 -0
- data/features/html/modal.html +17 -0
- data/features/html/modal_1.html +38 -0
- data/features/html/modal_2.html +27 -0
- data/features/html/nested_elements.html +52 -0
- data/features/html/nested_frame_1.html +1 -0
- data/features/html/nested_frame_2.html +11 -0
- data/features/html/nested_frame_3.html +14 -0
- data/features/html/nested_frames.html +10 -0
- data/features/html/static_elements.html +29 -23
- data/features/image.feature +8 -0
- data/features/link.feature +5 -0
- data/features/list_item.feature +5 -0
- data/features/modal_dialog.feature +9 -0
- data/features/nested_elements.feature +105 -0
- data/features/ordered_list.feature +6 -0
- data/features/page_level_actions.feature +48 -0
- data/features/paragraph.feature +33 -0
- data/features/radio_button.feature +6 -0
- data/features/select_list.feature +6 -1
- data/features/span.feature +6 -1
- data/features/step_definations/async_steps.rb +63 -0
- data/features/step_definations/button_steps.rb +25 -1
- data/features/step_definations/checkbox_steps.rb +5 -1
- data/features/step_definations/div_steps.rb +6 -1
- data/features/step_definations/element_steps.rb +55 -1
- data/features/step_definations/file_field_steps.rb +27 -0
- data/features/step_definations/form_steps.rb +8 -0
- data/features/step_definations/frame_steps.rb +112 -0
- data/features/step_definations/heading_steps.rb +39 -0
- data/features/step_definations/hidden_field_steps.rb +7 -3
- data/features/step_definations/image_steps.rb +7 -3
- data/features/step_definations/link_steps.rb +8 -3
- data/features/step_definations/list_item_steps.rb +9 -1
- data/features/step_definations/modal_dialog_steps.rb +38 -0
- data/features/step_definations/nested_elements_steps.rb +196 -0
- data/features/step_definations/ordered_list_steps.rb +11 -3
- data/features/step_definations/page_level_actions_steps.rb +72 -0
- data/features/step_definations/paragraph_steps.rb +15 -0
- data/features/step_definations/radio_button_steps.rb +5 -1
- data/features/step_definations/select_list_steps.rb +10 -2
- data/features/step_definations/span_steps.rb +5 -1
- data/features/step_definations/table_cell_steps.rb +5 -1
- data/features/step_definations/table_steps.rb +17 -3
- data/features/step_definations/text_area_steps.rb +18 -2
- data/features/step_definations/text_field_steps.rb +9 -1
- data/features/step_definations/unordered_list_steps.rb +11 -3
- data/features/support/env.rb +0 -15
- data/features/support/hooks.rb +7 -0
- data/features/support/page.rb +98 -1
- data/features/support/persistent_browser.rb +15 -0
- data/features/support/url_helper.rb +24 -1
- data/features/table.feature +7 -0
- data/features/table_cell.feature +6 -0
- data/features/text_area.feature +11 -0
- data/features/text_field.feature +6 -1
- data/features/unordered_list.feature +6 -0
- data/lib/druid.rb +251 -3
- data/lib/druid/accessors.rb +446 -158
- data/lib/druid/assist.rb +394 -0
- data/lib/druid/core_ext/string.rb +5 -0
- data/lib/druid/element_locators.rb +405 -0
- data/lib/druid/elements.rb +28 -0
- data/lib/druid/elements/button.rb +6 -1
- data/lib/druid/elements/check_box.rb +26 -0
- data/lib/druid/elements/div.rb +3 -1
- data/lib/druid/elements/element.rb +170 -5
- data/lib/druid/elements/file_field.rb +18 -0
- data/lib/druid/elements/form.rb +11 -0
- data/lib/druid/elements/heading.rb +14 -0
- data/lib/druid/elements/hidden_field.rb +12 -2
- data/lib/druid/elements/image.rb +13 -0
- data/lib/druid/elements/link.rb +2 -0
- data/lib/druid/elements/list_item.rb +3 -1
- data/lib/druid/elements/option.rb +9 -0
- data/lib/druid/elements/ordered_list.rb +4 -5
- data/lib/druid/elements/paragraph.rb +9 -0
- data/lib/druid/elements/radio_button.rb +25 -0
- data/lib/druid/elements/select_list.rb +10 -1
- data/lib/druid/elements/span.rb +3 -1
- data/lib/druid/elements/table.rb +20 -1
- data/lib/druid/elements/table_cell.rb +7 -0
- data/lib/druid/elements/table_row.rb +5 -1
- data/lib/druid/elements/text_area.rb +15 -1
- data/lib/druid/elements/text_field.rb +11 -1
- data/lib/druid/elements/unordered_list.rb +5 -5
- data/lib/druid/nested_elements.rb +103 -0
- data/lib/druid/page_factory.rb +4 -4
- data/lib/druid/page_populator.rb +71 -0
- data/spec/druid/accessors_spec.rb +789 -0
- data/spec/druid/druid_spec.rb +130 -7
- data/spec/druid/element_locators_spec.rb +160 -0
- data/spec/druid/elements/button_spec.rb +31 -0
- data/spec/druid/elements/check_box_spec.rb +38 -0
- data/spec/druid/elements/div_spec.rb +19 -0
- data/spec/druid/elements/element_spec.rb +150 -0
- data/spec/druid/elements/file_field_spec.rb +27 -0
- data/spec/druid/elements/form_spec.rb +27 -0
- data/spec/druid/elements/heading_spec.rb +39 -0
- data/spec/druid/elements/hidden_field_spec.rb +24 -0
- data/spec/druid/elements/image_spec.rb +32 -0
- data/spec/druid/elements/link_spec.rb +26 -0
- data/spec/druid/elements/list_item_spec.rb +19 -0
- data/spec/druid/elements/option_spec.rb +10 -0
- data/spec/druid/elements/ordered_list_spec.rb +42 -0
- data/spec/druid/elements/page_factory_spec.rb +40 -0
- data/spec/druid/elements/paragraph_spec.rb +21 -0
- data/spec/druid/elements/radio_button_spec.rb +38 -0
- data/spec/druid/elements/select_list_spec.rb +37 -0
- data/spec/druid/elements/span_spec.rb +19 -0
- data/spec/druid/elements/table_cell_spec.rb +23 -0
- data/spec/druid/elements/table_row_spec.rb +41 -0
- data/spec/druid/elements/table_spec.rb +52 -0
- data/spec/druid/elements/text_area_spec.rb +31 -0
- data/spec/druid/elements/text_field_spec.rb +31 -0
- data/spec/druid/elements/unordered_list_spec.rb +42 -0
- data/spec/druid/nested_element_spec.rb +128 -0
- data/spec/druid/page_populator_spec.rb +92 -0
- data/spec/spec_helper.rb +2 -1
- metadata +147 -27
@@ -8,11 +8,8 @@ module Druid
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def [](idx)
|
11
|
-
|
12
|
-
|
13
|
-
else
|
14
|
-
print "the sub element of ol is not li"+"\n"
|
15
|
-
end
|
11
|
+
li = element.li(:xpath, ".//li[#{idx+1}]")
|
12
|
+
Druid::Elements::ListItem.new(li)
|
16
13
|
end
|
17
14
|
|
18
15
|
def items
|
@@ -26,5 +23,7 @@ module Druid
|
|
26
23
|
end
|
27
24
|
|
28
25
|
end
|
26
|
+
|
27
|
+
Druid::Elements.tag_to_class[:ol] = Druid::Elements::OrderedList
|
29
28
|
end
|
30
29
|
end
|
@@ -2,6 +2,31 @@ module Druid
|
|
2
2
|
module Elements
|
3
3
|
class RadioButton < Element
|
4
4
|
|
5
|
+
def self.finders
|
6
|
+
super + [:value]
|
7
|
+
end
|
8
|
+
#
|
9
|
+
# Select the RadioButton
|
10
|
+
#
|
11
|
+
def select
|
12
|
+
element.set
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
# Clear the RadioButton
|
17
|
+
#
|
18
|
+
def clear
|
19
|
+
element.clear
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
# Return if it is selected
|
24
|
+
#
|
25
|
+
def selected?
|
26
|
+
element.set?
|
27
|
+
end
|
5
28
|
end
|
29
|
+
|
30
|
+
Druid::Elements.type_to_class[:radio] = Druid::Elements::RadioButton
|
6
31
|
end
|
7
32
|
end
|
@@ -7,12 +7,21 @@ module Druid
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def [](idx)
|
10
|
-
|
10
|
+
Druid::Elements::Option.new(options[idx])
|
11
11
|
end
|
12
12
|
|
13
13
|
def options
|
14
14
|
element.options
|
15
15
|
end
|
16
|
+
|
17
|
+
#
|
18
|
+
# Select a value from the list
|
19
|
+
#
|
20
|
+
def select(value)
|
21
|
+
element.select(value)
|
22
|
+
end
|
16
23
|
end
|
24
|
+
|
25
|
+
Druid::Elements.tag_to_class[:select] = Druid::Elements::SelectList
|
17
26
|
end
|
18
27
|
end
|
data/lib/druid/elements/span.rb
CHANGED
data/lib/druid/elements/table.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
module Druid
|
2
2
|
module Elements
|
3
3
|
class Table < Element
|
4
|
-
|
5
4
|
#
|
6
5
|
# Return the Druid::Elements::Table for the index provided. Index
|
7
6
|
# is zero based.
|
@@ -25,6 +24,26 @@ module Druid
|
|
25
24
|
end
|
26
25
|
end
|
27
26
|
|
27
|
+
#
|
28
|
+
# return the first row
|
29
|
+
#
|
30
|
+
# @return Druid::Elements::TableRow
|
31
|
+
#
|
32
|
+
def first_row
|
33
|
+
self[0]
|
34
|
+
end
|
35
|
+
|
36
|
+
#
|
37
|
+
# return the last row
|
38
|
+
#
|
39
|
+
# @return Druid::Elements::TableRow
|
40
|
+
#
|
41
|
+
def last_row
|
42
|
+
self[-1]
|
43
|
+
end
|
44
|
+
|
28
45
|
end
|
46
|
+
|
47
|
+
Druid::Elements.tag_to_class[:table] = Druid::Elements::Table
|
29
48
|
end
|
30
49
|
end
|
@@ -2,6 +2,13 @@ module Druid
|
|
2
2
|
module Elements
|
3
3
|
class TableCell < Element
|
4
4
|
|
5
|
+
def self.finders
|
6
|
+
super + [:text]
|
7
|
+
end
|
5
8
|
end
|
9
|
+
|
10
|
+
Druid::Elements.tag_to_class[:td] = Druid::Elements::TableCell
|
11
|
+
Druid::Elements.tag_to_class[:th] = Druid::Elements::TableCell
|
12
|
+
|
6
13
|
end
|
7
14
|
end
|
@@ -2,7 +2,8 @@ module Druid
|
|
2
2
|
module Elements
|
3
3
|
class TableRow < Element
|
4
4
|
def [](idx)
|
5
|
-
element[idx]
|
5
|
+
table_cell = element[idx]
|
6
|
+
Druid::Elements::TableCell.new(table_cell)
|
6
7
|
end
|
7
8
|
#
|
8
9
|
# Returns the number of rows in the table.
|
@@ -18,5 +19,8 @@ module Druid
|
|
18
19
|
end
|
19
20
|
|
20
21
|
end
|
22
|
+
|
23
|
+
Druid::Elements.tag_to_class[:tr] = Druid::Elements::TableRow
|
24
|
+
|
21
25
|
end
|
22
26
|
end
|
@@ -3,9 +3,23 @@ module Druid
|
|
3
3
|
class TextArea < Element
|
4
4
|
|
5
5
|
def self.finders
|
6
|
-
super + [:tag_name
|
6
|
+
super + [:tag_name]
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.mapping
|
10
|
+
super.merge({:css => :tag_name})
|
11
|
+
end
|
12
|
+
|
13
|
+
#
|
14
|
+
# Set the value of the TextArea
|
15
|
+
#
|
16
|
+
def value=(new_value)
|
17
|
+
element.send_keys(new_value)
|
7
18
|
end
|
8
19
|
|
9
20
|
end
|
21
|
+
|
22
|
+
Druid::Elements.tag_to_class[:textarea] = Druid::Elements::TextArea
|
23
|
+
|
10
24
|
end
|
11
25
|
end
|
@@ -3,9 +3,19 @@ module Druid
|
|
3
3
|
class TextField < Element
|
4
4
|
|
5
5
|
def self.finders
|
6
|
-
super + [:css, :tag_name, :text]
|
6
|
+
super + [:css, :tag_name, :text, :title]
|
7
7
|
end
|
8
8
|
|
9
|
+
#
|
10
|
+
# Set the value of the TextField
|
11
|
+
#
|
12
|
+
def value=(new_value)
|
13
|
+
element.set(new_value)
|
14
|
+
end
|
9
15
|
end
|
16
|
+
|
17
|
+
Druid::Elements.type_to_class[:text] = Druid::Elements::TextField
|
18
|
+
Druid::Elements.type_to_class[:password] = Druid::Elements::TextField
|
19
|
+
|
10
20
|
end
|
11
21
|
end
|
@@ -7,11 +7,8 @@ module Druid
|
|
7
7
|
end
|
8
8
|
|
9
9
|
def [](idx)
|
10
|
-
|
11
|
-
|
12
|
-
else
|
13
|
-
print "the sub element of ul is not li"+"\n"
|
14
|
-
end
|
10
|
+
li = element.li(:xpath,".//li[#{idx+1}]")
|
11
|
+
Druid::Elements::ListItem.new(li)
|
15
12
|
end
|
16
13
|
|
17
14
|
def items
|
@@ -24,5 +21,8 @@ module Druid
|
|
24
21
|
end
|
25
22
|
end
|
26
23
|
end
|
24
|
+
|
25
|
+
Druid::Elements.tag_to_class[:ul] = Druid::Elements::UnOrderedList
|
26
|
+
|
27
27
|
end
|
28
28
|
end
|
@@ -0,0 +1,103 @@
|
|
1
|
+
module Druid
|
2
|
+
module NestedElements
|
3
|
+
def link_element(identifier={:index => 0})
|
4
|
+
link_for(identifier)
|
5
|
+
end
|
6
|
+
|
7
|
+
def button_element(identifier={:index => 0})
|
8
|
+
button_for(identifier)
|
9
|
+
end
|
10
|
+
|
11
|
+
def text_field_element(identifier={:index => 0})
|
12
|
+
text_field_for(identifier)
|
13
|
+
end
|
14
|
+
|
15
|
+
def hidden_field_element(identifier={:index => 0})
|
16
|
+
hidden_field_for(identifier)
|
17
|
+
end
|
18
|
+
|
19
|
+
def text_area_element(identifier={:index => 0})
|
20
|
+
text_area_for(identifier)
|
21
|
+
end
|
22
|
+
|
23
|
+
def select_list_element(identifier={:index => 0})
|
24
|
+
select_list_for(identifier)
|
25
|
+
end
|
26
|
+
|
27
|
+
def checkbox_element(identifier={:index => 0})
|
28
|
+
checkbox_for(identifier)
|
29
|
+
end
|
30
|
+
|
31
|
+
def radio_button_element(identifier={:index => 0})
|
32
|
+
radio_button_for(identifier)
|
33
|
+
end
|
34
|
+
|
35
|
+
def div_element(identifier={:index => 0})
|
36
|
+
div_for(identifier)
|
37
|
+
end
|
38
|
+
|
39
|
+
def span_element(identifier={:index => 0})
|
40
|
+
span_for(identifier)
|
41
|
+
end
|
42
|
+
|
43
|
+
def table_element(identifier={:index => 0})
|
44
|
+
table_for(identifier)
|
45
|
+
end
|
46
|
+
|
47
|
+
def cell_element(identifier={:index => 0})
|
48
|
+
cell_for(identifier)
|
49
|
+
end
|
50
|
+
|
51
|
+
def image_element(identifier={:index => 0})
|
52
|
+
image_for(identifier)
|
53
|
+
end
|
54
|
+
|
55
|
+
def form_element(identifier={:index => 0})
|
56
|
+
form_for(identifier)
|
57
|
+
end
|
58
|
+
|
59
|
+
def ordered_list_element(identifier={:index => 0})
|
60
|
+
ordered_list_for(identifier)
|
61
|
+
end
|
62
|
+
|
63
|
+
def unordered_list_element(identifier={:index => 0})
|
64
|
+
unordered_list_for(identifier)
|
65
|
+
end
|
66
|
+
|
67
|
+
def list_item_element(identifier={:index => 0})
|
68
|
+
list_item_for(identifier)
|
69
|
+
end
|
70
|
+
|
71
|
+
def h1_element(identifier={:index => 0})
|
72
|
+
h1_for(identifier)
|
73
|
+
end
|
74
|
+
|
75
|
+
def h2_element(identifier={:index => 0})
|
76
|
+
h2_for(identifier)
|
77
|
+
end
|
78
|
+
|
79
|
+
def h3_element(identifier={:index => 0})
|
80
|
+
h3_for(identifier)
|
81
|
+
end
|
82
|
+
|
83
|
+
def h4_element(identifier={:index => 0})
|
84
|
+
h4_for(identifier)
|
85
|
+
end
|
86
|
+
|
87
|
+
def h5_element(identifier={:index => 0})
|
88
|
+
h5_for(identifier)
|
89
|
+
end
|
90
|
+
|
91
|
+
def h6_element(identifier={:index => 0})
|
92
|
+
h6_for(identifier)
|
93
|
+
end
|
94
|
+
|
95
|
+
def paragraph_element(identifier={:index => 0})
|
96
|
+
paragraph_for(identifier)
|
97
|
+
end
|
98
|
+
|
99
|
+
def file_field_element(identifier={:index =>0})
|
100
|
+
file_field_for(identifier)
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
data/lib/druid/page_factory.rb
CHANGED
@@ -19,7 +19,7 @@ module Druid
|
|
19
19
|
# end
|
20
20
|
#
|
21
21
|
module PageFactory
|
22
|
-
attr_accessor :page
|
22
|
+
# attr_accessor :page
|
23
23
|
#
|
24
24
|
# Create and navigate to a page object. The navigation will only work if the
|
25
25
|
# 'page_url' method was call on the page object.
|
@@ -40,9 +40,9 @@ module Druid
|
|
40
40
|
# @return [PageObject] the newly created page object
|
41
41
|
#
|
42
42
|
def on_page(page_class, visit=false, &block)
|
43
|
-
|
44
|
-
yield
|
45
|
-
|
43
|
+
@current_page = page_class.new(@driver, visit)
|
44
|
+
yield @current_page if block_given?
|
45
|
+
@current_page
|
46
46
|
end
|
47
47
|
# def visit_page(page_class, &block)
|
48
48
|
# page = page_class.new(@driver, true)
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Druid
|
2
|
+
module PagePopulator
|
3
|
+
#
|
4
|
+
# This method will populate all matched page TextFields,
|
5
|
+
# TextAreas, SelectLists, FileFields, Checkboxes, and Radio Buttons from the
|
6
|
+
# Hash passed as an argument. The way it find an element is by
|
7
|
+
# matching the Hash key to the name you provided when declaring
|
8
|
+
# the element on your page.
|
9
|
+
#
|
10
|
+
# Checkbox and Radio Button values must be true or false.
|
11
|
+
#
|
12
|
+
# @example
|
13
|
+
# class ExamplePage
|
14
|
+
# include PageObject
|
15
|
+
#
|
16
|
+
# text_field(:username, :id => 'username_id')
|
17
|
+
# checkbox(:active, :id => 'active_id')
|
18
|
+
# end
|
19
|
+
#
|
20
|
+
# ...
|
21
|
+
#
|
22
|
+
# @browser = Watir::Browser.new :firefox
|
23
|
+
# example_page = ExamplePage.new(@browser)
|
24
|
+
# example_page.populate_page_with :username => 'a name', :active => true
|
25
|
+
#
|
26
|
+
# @param [Hash] the data to use to populate this page. The key
|
27
|
+
# can be either a string or a symbol. The value must be a string
|
28
|
+
# for TextField, TextArea, SelectList and FileField must be true or
|
29
|
+
# false for a Checkbox or RadioButton.
|
30
|
+
#
|
31
|
+
def populate_page_with(data)
|
32
|
+
data.each do |key, value|
|
33
|
+
populate_checkbox(key, value) if is_checkbox?(key) and is_enabled?(key)
|
34
|
+
populate_radiobutton(key, value) if is_radiobutton?(key) and is_enabled?(key)
|
35
|
+
populate_text(key, value) if is_text?(key) and is_enabled?(key)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
def populate_text(key, value)
|
42
|
+
self.send "#{key}=", value
|
43
|
+
end
|
44
|
+
|
45
|
+
def populate_checkbox(key, value)
|
46
|
+
return self.send "check_#{key}" if value
|
47
|
+
return self.send "uncheck_#{key}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def populate_radiobutton(key, value)
|
51
|
+
return self.send "select_#{key}" if value
|
52
|
+
return self.send "clear_#{key}"
|
53
|
+
end
|
54
|
+
|
55
|
+
def is_text?(key)
|
56
|
+
respond_to?("#{key}=".to_sym)
|
57
|
+
end
|
58
|
+
|
59
|
+
def is_checkbox?(key)
|
60
|
+
respond_to?("check_#{key}".to_sym)
|
61
|
+
end
|
62
|
+
|
63
|
+
def is_radiobutton?(key)
|
64
|
+
respond_to?("select_#{key}".to_sym)
|
65
|
+
end
|
66
|
+
|
67
|
+
def is_enabled?(key)
|
68
|
+
self.send("#{key}_element").enabled?
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,789 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
class AccessorsTestDruid
|
4
|
+
include Druid
|
5
|
+
|
6
|
+
page_url "http://apple.com"
|
7
|
+
link(:google_search, :link => 'Google Search')
|
8
|
+
text_field(:first_name, :id => 'first_name')
|
9
|
+
select_list(:state, :id => 'state')
|
10
|
+
checkbox(:active, :id => 'is_active_id')
|
11
|
+
button(:click_me, :id => 'button_submit')
|
12
|
+
radio_button(:first, :id => 'first_choice')
|
13
|
+
div(:message, :id => 'message_id')
|
14
|
+
table(:cart, :id => 'cart_id')
|
15
|
+
cell(:total, :id => 'total')
|
16
|
+
span(:alert, :id => 'alert_id')
|
17
|
+
image(:logo, :id => 'logo')
|
18
|
+
hidden_field(:social_security_number, :id => 'ssn')
|
19
|
+
form(:login, :id => 'login')
|
20
|
+
text_area(:address, :id => 'address')
|
21
|
+
list_item(:item_one, :id => 'one')
|
22
|
+
unordered_list(:menu, :id => 'main_menu')
|
23
|
+
ordered_list(:top_five, :id => 'top')
|
24
|
+
h1(:heading1, :id => 'main_heading')
|
25
|
+
h2(:heading2, :id => 'main_heading')
|
26
|
+
h3(:heading3, :id => 'main_heading')
|
27
|
+
h4(:heading4, :id => 'main_heading')
|
28
|
+
h5(:heading5, :id => 'main_heading')
|
29
|
+
h6(:heading6, :id => 'main_heading')
|
30
|
+
paragraph(:first_para, :id => 'first')
|
31
|
+
file_field(:upload_me, :id => 'the_file')
|
32
|
+
end
|
33
|
+
|
34
|
+
class BlockDruid
|
35
|
+
include Druid
|
36
|
+
|
37
|
+
text_field :first_name do |element|
|
38
|
+
"text_field"
|
39
|
+
end
|
40
|
+
hidden_field :secret do |element|
|
41
|
+
"hidden_field"
|
42
|
+
end
|
43
|
+
text_area :address do |element|
|
44
|
+
"text_area"
|
45
|
+
end
|
46
|
+
select_list :state do |element|
|
47
|
+
"select_list"
|
48
|
+
end
|
49
|
+
link :continue do |element|
|
50
|
+
"link"
|
51
|
+
end
|
52
|
+
checkbox :active do |element|
|
53
|
+
"checkbox"
|
54
|
+
end
|
55
|
+
radio_button :first do |element|
|
56
|
+
"radio_button"
|
57
|
+
end
|
58
|
+
button :click_me do |element|
|
59
|
+
"button"
|
60
|
+
end
|
61
|
+
div :footer do |element|
|
62
|
+
"div"
|
63
|
+
end
|
64
|
+
span :alert do |element|
|
65
|
+
"span"
|
66
|
+
end
|
67
|
+
table :cart do |element|
|
68
|
+
"table"
|
69
|
+
end
|
70
|
+
cell :total do |element|
|
71
|
+
"cell"
|
72
|
+
end
|
73
|
+
image :logo do |element|
|
74
|
+
"image"
|
75
|
+
end
|
76
|
+
form :login do |element|
|
77
|
+
"form"
|
78
|
+
end
|
79
|
+
list_item :item_one do |element|
|
80
|
+
"list_item"
|
81
|
+
end
|
82
|
+
unordered_list :menu do |element|
|
83
|
+
"unordered_list"
|
84
|
+
end
|
85
|
+
ordered_list :top_five do |element|
|
86
|
+
"ordered_list"
|
87
|
+
end
|
88
|
+
h1 :heading1 do |element|
|
89
|
+
"h1"
|
90
|
+
end
|
91
|
+
h2 :heading2 do |element|
|
92
|
+
"h2"
|
93
|
+
end
|
94
|
+
h3 :heading3 do |element|
|
95
|
+
"h3"
|
96
|
+
end
|
97
|
+
h4 :heading4 do |element|
|
98
|
+
"h4"
|
99
|
+
end
|
100
|
+
h5 :heading5 do |element|
|
101
|
+
"h5"
|
102
|
+
end
|
103
|
+
h6 :heading6 do |element|
|
104
|
+
"h6"
|
105
|
+
end
|
106
|
+
paragraph :first_para do |element|
|
107
|
+
"p"
|
108
|
+
end
|
109
|
+
file_field :a_file do |element|
|
110
|
+
"file_field"
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
class TestDruidBackUp
|
115
|
+
include Druid
|
116
|
+
end
|
117
|
+
|
118
|
+
describe Druid::Accessors do
|
119
|
+
let(:driver) { mock_driver }
|
120
|
+
let(:druid) { AccessorsTestDruid.new(driver) }
|
121
|
+
let(:block_druid) { BlockDruid.new(driver) }
|
122
|
+
|
123
|
+
|
124
|
+
describe "goto a page" do
|
125
|
+
it "should navigate to a page when requested" do
|
126
|
+
expect(driver).to receive(:goto)
|
127
|
+
page = AccessorsTestDruid.new(driver, true)
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should not navigate to a page when not requested" do
|
131
|
+
expect(driver).not_to receive(:goto)
|
132
|
+
page = AccessorsTestDruid.new(driver)
|
133
|
+
end
|
134
|
+
|
135
|
+
it "should not navigate to a page when 'page_url' not specified" do
|
136
|
+
expect(driver).not_to receive(:goto)
|
137
|
+
page = TestDruidBackUp.new(driver,true)
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
describe "check_box accessors" do
|
142
|
+
context "when called on a page object" do
|
143
|
+
it "should generate accessor methods" do
|
144
|
+
expect(druid).to respond_to :check_active
|
145
|
+
expect(druid).to respond_to :uncheck_active
|
146
|
+
expect(druid).to respond_to :active_checked?
|
147
|
+
expect(druid).to respond_to :active_element
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should call a block on the element method when present" do
|
151
|
+
expect(block_druid.active_element).to eql "checkbox"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
155
|
+
context "implementation" do
|
156
|
+
it "should check a check box element" do
|
157
|
+
expect(driver).to receive_message_chain(:checkbox, :set)
|
158
|
+
druid.check_active
|
159
|
+
end
|
160
|
+
|
161
|
+
it "should clear a check box element" do
|
162
|
+
expect(driver).to receive_message_chain(:checkbox, :clear)
|
163
|
+
druid.uncheck_active
|
164
|
+
end
|
165
|
+
|
166
|
+
it "should know if a check box element is selected" do
|
167
|
+
expect(driver).to receive_message_chain(:checkbox, :set?).and_return(true)
|
168
|
+
expect(druid.active_checked?).to be true
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should retreive a check box element" do
|
172
|
+
expect(driver).to receive(:checkbox)
|
173
|
+
expect(druid.active_element).to be_instance_of Druid::Elements::CheckBox
|
174
|
+
end
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
describe "link accessors" do
|
179
|
+
|
180
|
+
context "when called on a page object" do
|
181
|
+
it "should generate accessor methods" do
|
182
|
+
expect(druid).to respond_to(:google_search)
|
183
|
+
expect(druid).to respond_to(:google_search_element)
|
184
|
+
end
|
185
|
+
|
186
|
+
it "should call a block on the element method when present" do
|
187
|
+
expect(block_druid.continue_element).to eql "link"
|
188
|
+
end
|
189
|
+
end
|
190
|
+
|
191
|
+
context "implementation" do
|
192
|
+
it "should select a link" do
|
193
|
+
expect(driver).to receive_message_chain(:link, :click)
|
194
|
+
druid.google_search
|
195
|
+
end
|
196
|
+
|
197
|
+
it "should retreive a link element" do
|
198
|
+
expect(driver).to receive(:link)
|
199
|
+
expect(druid.google_search_element).to be_instance_of Druid::Elements::Link
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
describe "select_list accessors" do
|
205
|
+
|
206
|
+
context "when called on a page object" do
|
207
|
+
it "should generate accessor methods" do
|
208
|
+
expect(druid).to respond_to :state
|
209
|
+
expect(druid).to respond_to :state=
|
210
|
+
expect(druid).to respond_to :state_element
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should call a block on the element method when present" do
|
214
|
+
expect(block_druid.state_element).to eql "select_list"
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
context "implementation" do
|
219
|
+
it "should get the current item from a select list" do
|
220
|
+
expect(driver).to receive_message_chain(:select_list, :value).and_return('OH')
|
221
|
+
expect(druid.state).to eql 'OH'
|
222
|
+
end
|
223
|
+
|
224
|
+
it "should set the current item fo a select list" do
|
225
|
+
expect(driver).to receive(:select_list).and_return driver
|
226
|
+
expect(driver).to receive(:select).with('OH')
|
227
|
+
druid.state = 'OH'
|
228
|
+
end
|
229
|
+
|
230
|
+
it "should retreive a select list element" do
|
231
|
+
expect(driver).to receive(:select_list)
|
232
|
+
expect(druid.state_element).to be_instance_of Druid::Elements::SelectList
|
233
|
+
end
|
234
|
+
end
|
235
|
+
end
|
236
|
+
|
237
|
+
describe "text_field accessors" do
|
238
|
+
|
239
|
+
context "when called on a page object" do
|
240
|
+
it "should generate accessor methods" do
|
241
|
+
expect(druid).to respond_to(:first_name)
|
242
|
+
expect(druid).to respond_to(:first_name=)
|
243
|
+
expect(druid).to respond_to(:first_name_element)
|
244
|
+
end
|
245
|
+
|
246
|
+
it "should call a block on the element method when present" do
|
247
|
+
expect(block_druid.first_name_element).to eql "text_field"
|
248
|
+
end
|
249
|
+
end
|
250
|
+
|
251
|
+
context "implementation" do
|
252
|
+
it "should get the text from the text field element" do
|
253
|
+
expect(driver).to receive_message_chain(:text_field, :value).and_return('Kim')
|
254
|
+
expect(druid.first_name).to eql 'Kim'
|
255
|
+
end
|
256
|
+
|
257
|
+
it "should set some text on a text field element" do
|
258
|
+
expect(driver).to receive_message_chain(:text_field, :set).with('Kim')
|
259
|
+
druid.first_name = 'Kim'
|
260
|
+
end
|
261
|
+
|
262
|
+
it "should retreive text field element" do
|
263
|
+
expect(driver).to receive(:text_field)
|
264
|
+
expect(druid.first_name_element).to be_instance_of Druid::Elements::TextField
|
265
|
+
end
|
266
|
+
end
|
267
|
+
end
|
268
|
+
|
269
|
+
describe "button accessors" do
|
270
|
+
context "when called on a page object" do
|
271
|
+
it "should generate accessor methods" do
|
272
|
+
expect(druid).to respond_to :click_me
|
273
|
+
expect(druid).to respond_to :click_me_element
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should call a block on the element method when present" do
|
277
|
+
expect(block_druid.click_me_element).to eql "button"
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
context "implementation" do
|
282
|
+
it "should select a button" do
|
283
|
+
expect(driver).to receive_message_chain(:button, :click)
|
284
|
+
druid.click_me
|
285
|
+
end
|
286
|
+
|
287
|
+
it "should retreive a button element" do
|
288
|
+
expect(driver).to receive(:button)
|
289
|
+
expect(druid.click_me_element).to be_instance_of Druid::Elements::Button
|
290
|
+
end
|
291
|
+
end
|
292
|
+
end
|
293
|
+
|
294
|
+
describe "radio accessors" do
|
295
|
+
context "when called on a page object" do
|
296
|
+
it "should generate accessor methods" do
|
297
|
+
expect(druid).to respond_to :first_element
|
298
|
+
expect(druid).to respond_to :select_first
|
299
|
+
expect(druid).to respond_to :first_selected?
|
300
|
+
expect(druid).to respond_to :clear_first
|
301
|
+
end
|
302
|
+
|
303
|
+
it "should call a block on the element method when present" do
|
304
|
+
expect(block_druid.first_element).to eql "radio_button"
|
305
|
+
end
|
306
|
+
end
|
307
|
+
|
308
|
+
context "implementation" do
|
309
|
+
it "should select a radio button" do
|
310
|
+
expect(driver).to receive_message_chain(:radio, :set)
|
311
|
+
druid.select_first
|
312
|
+
end
|
313
|
+
|
314
|
+
it "should clear a radio button" do
|
315
|
+
expect(driver).to receive_message_chain(:radio, :clear)
|
316
|
+
druid.clear_first
|
317
|
+
end
|
318
|
+
|
319
|
+
it "should determine if a radio is selected" do
|
320
|
+
expect(driver).to receive_message_chain(:radio, :set?).and_return(true)
|
321
|
+
expect(druid.first_selected?).to be true
|
322
|
+
end
|
323
|
+
|
324
|
+
it "should retreive a radio button element" do
|
325
|
+
expect(driver).to receive(:radio)
|
326
|
+
expect(druid.first_element).to be_instance_of Druid::Elements::RadioButton
|
327
|
+
end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
describe "div accessors" do
|
332
|
+
context "when called on a page object" do
|
333
|
+
it "should generate accessor methods" do
|
334
|
+
expect(druid).to respond_to :message
|
335
|
+
expect(druid).to respond_to :message_element
|
336
|
+
end
|
337
|
+
|
338
|
+
it "should call a block on the element method when present" do
|
339
|
+
expect(block_druid.footer_element).to eql "div"
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
context "implementation" do
|
344
|
+
it "should retreive the text from a div" do
|
345
|
+
expect(driver).to receive_message_chain(:div, :text).and_return("Message from div")
|
346
|
+
expect(druid.message).to eql "Message from div"
|
347
|
+
end
|
348
|
+
|
349
|
+
it "should retreive a div element" do
|
350
|
+
expect(driver).to receive(:div)
|
351
|
+
expect(druid.message_element).to be_instance_of Druid::Elements::Div
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
describe "table accessors" do
|
357
|
+
context "when called on a page object" do
|
358
|
+
it "should generate accessor methods" do
|
359
|
+
expect(druid).to respond_to :cart_element
|
360
|
+
end
|
361
|
+
|
362
|
+
it "should call a block on the element method when present" do
|
363
|
+
expect(block_druid.cart_element).to eql "table"
|
364
|
+
end
|
365
|
+
end
|
366
|
+
|
367
|
+
context "implementation" do
|
368
|
+
it "should retrieve the table element from the page" do
|
369
|
+
expect(driver).to receive(:table)
|
370
|
+
expect(druid.cart_element).to be_instance_of Druid::Elements::Table
|
371
|
+
end
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
describe "table cell accessors" do
|
376
|
+
context "when called on a page object" do
|
377
|
+
it "should generate accessor methods" do
|
378
|
+
expect(druid).to respond_to :total
|
379
|
+
expect(druid).to respond_to :total_element
|
380
|
+
end
|
381
|
+
|
382
|
+
it "should call a block on the element method when present" do
|
383
|
+
expect(block_druid.total_cell).to eql "cell"
|
384
|
+
end
|
385
|
+
end
|
386
|
+
|
387
|
+
context "implementation" do
|
388
|
+
it "should retrieve the text from the cell" do
|
389
|
+
expect(driver).to receive_message_chain(:td, :text).and_return("10.00")
|
390
|
+
expect(druid.total).to eql "10.00"
|
391
|
+
end
|
392
|
+
|
393
|
+
it "should retrieve the cell element from the page" do
|
394
|
+
expect(driver).to receive(:td)
|
395
|
+
expect(druid.total_element).to be_instance_of Druid::Elements::TableCell
|
396
|
+
end
|
397
|
+
end
|
398
|
+
end
|
399
|
+
|
400
|
+
describe "span accessors" do
|
401
|
+
context "when called on a page object" do
|
402
|
+
it "should generate accessor methods" do
|
403
|
+
expect(druid).to respond_to :alert
|
404
|
+
expect(druid).to respond_to :alert_element
|
405
|
+
end
|
406
|
+
|
407
|
+
it "should call a block on the element method when present" do
|
408
|
+
expect(block_druid.alert_element).to eql "span"
|
409
|
+
end
|
410
|
+
end
|
411
|
+
|
412
|
+
context "implementation" do
|
413
|
+
it "should retrieve the text from a span" do
|
414
|
+
expect(driver).to receive_message_chain(:span, :text).and_return('Alert')
|
415
|
+
expect(druid.alert).to eql 'Alert'
|
416
|
+
end
|
417
|
+
|
418
|
+
it "should retrieve the span element from the page" do
|
419
|
+
expect(driver).to receive(:span)
|
420
|
+
expect(druid.alert_element).to be_instance_of Druid::Elements::Span
|
421
|
+
end
|
422
|
+
end
|
423
|
+
end
|
424
|
+
|
425
|
+
describe "image accessors" do
|
426
|
+
context "when called on a page object" do
|
427
|
+
it "should generate accessor methods" do
|
428
|
+
expect(druid).to respond_to :logo_element
|
429
|
+
end
|
430
|
+
|
431
|
+
it "should call a block on the element method when present " do
|
432
|
+
expect(block_druid.logo_element).to eql "image"
|
433
|
+
end
|
434
|
+
end
|
435
|
+
|
436
|
+
context "implementation" do
|
437
|
+
it "should retrieve the image element from the page" do
|
438
|
+
expect(driver).to receive(:image)
|
439
|
+
expect(druid.logo_element).to be_instance_of Druid::Elements::Image
|
440
|
+
end
|
441
|
+
end
|
442
|
+
end
|
443
|
+
|
444
|
+
describe "hidden field accessors" do
|
445
|
+
context "when called on a page object" do
|
446
|
+
it "should generate accessor methods" do
|
447
|
+
expect(druid).to respond_to :social_security_number
|
448
|
+
expect(druid).to respond_to :social_security_number_element
|
449
|
+
end
|
450
|
+
|
451
|
+
it "should call a block on the element method when present" do
|
452
|
+
expect(block_druid.secret_element).to eql "hidden_field"
|
453
|
+
end
|
454
|
+
end
|
455
|
+
|
456
|
+
context "implementation" do
|
457
|
+
it "should get the text from a hidden field" do
|
458
|
+
expect(driver).to receive_message_chain(:hidden, :value).and_return('value')
|
459
|
+
expect(druid.social_security_number).to eql 'value'
|
460
|
+
end
|
461
|
+
|
462
|
+
it "should retrieve a hidden field element" do
|
463
|
+
expect(driver).to receive(:hidden)
|
464
|
+
expect(druid.social_security_number_element).to be_instance_of Druid::Elements::HiddenField
|
465
|
+
end
|
466
|
+
end
|
467
|
+
end
|
468
|
+
|
469
|
+
describe "form accessors" do
|
470
|
+
context "when called on a page object" do
|
471
|
+
it "should generate accessor methods" do
|
472
|
+
expect(druid).to respond_to :login_element
|
473
|
+
end
|
474
|
+
|
475
|
+
it "should call a block on the element method when present" do
|
476
|
+
expect(block_druid.login_element).to eql "form"
|
477
|
+
end
|
478
|
+
end
|
479
|
+
|
480
|
+
context "implementation" do
|
481
|
+
it "should retrieve the form element from the page" do
|
482
|
+
expect(driver).to receive(:form)
|
483
|
+
expect(druid.login_element).to be_instance_of Druid::Elements::Form
|
484
|
+
end
|
485
|
+
end
|
486
|
+
end
|
487
|
+
|
488
|
+
describe "text area accessors" do
|
489
|
+
context "when called on a page object" do
|
490
|
+
it "should generate accessor methods" do
|
491
|
+
expect(druid).to respond_to :address
|
492
|
+
expect(druid).to respond_to :address=
|
493
|
+
expect(druid).to respond_to :address_element
|
494
|
+
end
|
495
|
+
|
496
|
+
it "should call a block on the element method when present" do
|
497
|
+
expect(block_druid.address_element).to eql "text_area"
|
498
|
+
end
|
499
|
+
end
|
500
|
+
|
501
|
+
context "implementation" do
|
502
|
+
it "should set some text on the text area" do
|
503
|
+
expect(driver).to receive_message_chain(:textarea, :send_keys).with('123 main street')
|
504
|
+
druid.address='123 main street'
|
505
|
+
end
|
506
|
+
|
507
|
+
it "should get the text from the text area" do
|
508
|
+
expect(driver).to receive_message_chain(:textarea, :value).and_return('123 main street')
|
509
|
+
expect(druid.address).to eql '123 main street'
|
510
|
+
end
|
511
|
+
|
512
|
+
it "should retrieve a text area element" do
|
513
|
+
expect(driver).to receive(:textarea)
|
514
|
+
expect(druid.address_element).to be_instance_of Druid::Elements::TextArea
|
515
|
+
end
|
516
|
+
end
|
517
|
+
end
|
518
|
+
|
519
|
+
describe "list item accessors" do
|
520
|
+
context "when called on a page object" do
|
521
|
+
it "should generate accessor methods" do
|
522
|
+
expect(druid).to respond_to :item_one
|
523
|
+
expect(druid).to respond_to :item_one_element
|
524
|
+
end
|
525
|
+
|
526
|
+
it "should call a block on the element method when present" do
|
527
|
+
expect(block_druid.item_one_element).to eql "list_item"
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
context "implementation" do
|
532
|
+
it "should retrieve the text from the list item" do
|
533
|
+
expect(driver).to receive_message_chain(:li, :text).and_return('value')
|
534
|
+
expect(druid.item_one).to eql 'value'
|
535
|
+
end
|
536
|
+
|
537
|
+
it "should retrieve the list item element from the page" do
|
538
|
+
expect(driver).to receive(:li)
|
539
|
+
expect(druid.item_one_element).to be_instance_of Druid::Elements::ListItem
|
540
|
+
end
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
describe "unordered list accessors" do
|
545
|
+
context "when called on a page object" do
|
546
|
+
it "should generate accessor methods" do
|
547
|
+
expect(druid).to respond_to :menu_element
|
548
|
+
end
|
549
|
+
|
550
|
+
it "should call a block on the element method when present" do
|
551
|
+
expect(block_druid.menu_element).to eql "unordered_list"
|
552
|
+
end
|
553
|
+
end
|
554
|
+
|
555
|
+
context "implementation" do
|
556
|
+
it "should retrieve the element from the page" do
|
557
|
+
expect(driver).to receive(:ul)
|
558
|
+
expect(druid.menu_element).to be_instance_of Druid::Elements::UnOrderedList
|
559
|
+
end
|
560
|
+
end
|
561
|
+
end
|
562
|
+
|
563
|
+
describe "ordered list accessors" do
|
564
|
+
context "when called on a page object" do
|
565
|
+
it "should generate accessor methods" do
|
566
|
+
expect(druid).to respond_to :top_five_element
|
567
|
+
end
|
568
|
+
|
569
|
+
it "should call a block on the element method when present" do
|
570
|
+
expect(block_druid.top_five_element).to eql "ordered_list"
|
571
|
+
end
|
572
|
+
end
|
573
|
+
|
574
|
+
context "implementation" do
|
575
|
+
it "should retrieve the element from the page" do
|
576
|
+
expect(driver).to receive(:ol)
|
577
|
+
expect(druid.top_five_element).to be_instance_of Druid::Elements::OrderedList
|
578
|
+
end
|
579
|
+
end
|
580
|
+
end
|
581
|
+
|
582
|
+
describe "h1 accessors" do
|
583
|
+
context "when called on a page object" do
|
584
|
+
it "should generate accessor methods" do
|
585
|
+
expect(druid).to respond_to :heading1
|
586
|
+
expect(druid).to respond_to :heading1_element
|
587
|
+
end
|
588
|
+
|
589
|
+
it "should call a block on the element method when present" do
|
590
|
+
expect(block_druid.heading1_element).to eql "h1"
|
591
|
+
end
|
592
|
+
end
|
593
|
+
|
594
|
+
context "implementation" do
|
595
|
+
it "should retrieve the text from the h1" do
|
596
|
+
expect(driver).to receive(:h1).and_return(driver)
|
597
|
+
expect(driver).to receive(:text).and_return("value")
|
598
|
+
expect(druid.heading1).to eql "value"
|
599
|
+
end
|
600
|
+
|
601
|
+
it "should retrieve the element from the page" do
|
602
|
+
expect(driver).to receive(:h1).and_return(driver)
|
603
|
+
expect(druid.heading1_element).to be_instance_of Druid::Elements::Heading
|
604
|
+
end
|
605
|
+
end
|
606
|
+
end
|
607
|
+
|
608
|
+
describe "h2 accessors" do
|
609
|
+
context "when called on a page object" do
|
610
|
+
it "should generate accessor methods" do
|
611
|
+
expect(druid).to respond_to(:heading2)
|
612
|
+
expect(druid).to respond_to(:heading2_element)
|
613
|
+
end
|
614
|
+
|
615
|
+
it "should call a block on the element method when present" do
|
616
|
+
expect(block_druid.heading2_element).to eql "h2"
|
617
|
+
end
|
618
|
+
end
|
619
|
+
|
620
|
+
context "implementation" do
|
621
|
+
it "should retrieve the text from the h2" do
|
622
|
+
expect(driver).to receive(:h2).and_return(driver)
|
623
|
+
expect(driver).to receive(:text).and_return("value")
|
624
|
+
expect(druid.heading2).to eql "value"
|
625
|
+
end
|
626
|
+
|
627
|
+
it "should retrieve the element from the page" do
|
628
|
+
expect(driver).to receive(:h2).and_return(driver)
|
629
|
+
expect(druid.heading2_element).to be_instance_of Druid::Elements::Heading
|
630
|
+
end
|
631
|
+
end
|
632
|
+
end
|
633
|
+
|
634
|
+
describe "h3 accessors" do
|
635
|
+
context "when called on a page object" do
|
636
|
+
it "should generate accessor methods" do
|
637
|
+
expect(druid).to respond_to(:heading3)
|
638
|
+
expect(druid).to respond_to(:heading3_element)
|
639
|
+
end
|
640
|
+
|
641
|
+
it "should call a block on the element method when present" do
|
642
|
+
expect(block_druid.heading3_element).to eql "h3"
|
643
|
+
end
|
644
|
+
end
|
645
|
+
|
646
|
+
context "implementation" do
|
647
|
+
it "should retrieve the text from the h3" do
|
648
|
+
expect(driver).to receive(:h3).and_return(driver)
|
649
|
+
expect(driver).to receive(:text).and_return("value")
|
650
|
+
expect(druid.heading3).to eql "value"
|
651
|
+
end
|
652
|
+
|
653
|
+
it "should retrieve the element from the page" do
|
654
|
+
expect(driver).to receive(:h3).and_return(driver)
|
655
|
+
expect(druid.heading3_element).to be_instance_of Druid::Elements::Heading
|
656
|
+
end
|
657
|
+
end
|
658
|
+
end
|
659
|
+
|
660
|
+
describe "h4 accessors" do
|
661
|
+
context "when called on a page object" do
|
662
|
+
it "should generate accessor methods" do
|
663
|
+
expect(druid).to respond_to(:heading4)
|
664
|
+
expect(druid).to respond_to(:heading4_element)
|
665
|
+
end
|
666
|
+
|
667
|
+
it "should call a block on the element method when present" do
|
668
|
+
expect(block_druid.heading4_element).to eql "h4"
|
669
|
+
end
|
670
|
+
end
|
671
|
+
|
672
|
+
context "implementation" do
|
673
|
+
it "should retrieve the text from the h4" do
|
674
|
+
expect(driver).to receive(:h4).and_return(driver)
|
675
|
+
expect(driver).to receive(:text).and_return("value")
|
676
|
+
expect(druid.heading4).to eql "value"
|
677
|
+
end
|
678
|
+
|
679
|
+
it "should retrieve the element from the page" do
|
680
|
+
expect(driver).to receive(:h4).and_return(driver)
|
681
|
+
expect(druid.heading4_element).to be_instance_of Druid::Elements::Heading
|
682
|
+
end
|
683
|
+
end
|
684
|
+
end
|
685
|
+
|
686
|
+
describe "h5 accessors" do
|
687
|
+
context "when called on a page object" do
|
688
|
+
it "should generate accessor methods" do
|
689
|
+
expect(druid).to respond_to(:heading5)
|
690
|
+
expect(druid).to respond_to(:heading5_element)
|
691
|
+
end
|
692
|
+
|
693
|
+
it "should call a block on the element method present" do
|
694
|
+
expect(block_druid.heading5_element).to eql "h5"
|
695
|
+
end
|
696
|
+
end
|
697
|
+
|
698
|
+
context "implementation" do
|
699
|
+
it "should retrieve the text from the h5" do
|
700
|
+
expect(driver).to receive(:h5).and_return(driver)
|
701
|
+
expect(driver).to receive(:text).and_return("value")
|
702
|
+
expect(druid.heading5).to eql "value"
|
703
|
+
end
|
704
|
+
|
705
|
+
it "should retrieve the element from the page" do
|
706
|
+
expect(driver).to receive(:h5).and_return(driver)
|
707
|
+
expect(druid.heading5_element).to be_instance_of Druid::Elements::Heading
|
708
|
+
end
|
709
|
+
end
|
710
|
+
end
|
711
|
+
|
712
|
+
describe "h6 accessors" do
|
713
|
+
context "when called on a page object" do
|
714
|
+
it "should generate accessor methods" do
|
715
|
+
expect(druid).to respond_to(:heading6)
|
716
|
+
expect(druid).to respond_to(:heading6_element)
|
717
|
+
end
|
718
|
+
|
719
|
+
it "should call a block on the element method present" do
|
720
|
+
expect(block_druid.heading6_element).to eql "h6"
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
724
|
+
context "implementation" do
|
725
|
+
it "should retrieve the text from the h6" do
|
726
|
+
expect(driver).to receive(:h6).and_return(driver)
|
727
|
+
expect(driver).to receive(:text).and_return("value")
|
728
|
+
expect(druid.heading6).to eql "value"
|
729
|
+
end
|
730
|
+
|
731
|
+
it "should retrieve the element from the page" do
|
732
|
+
expect(driver).to receive(:h6).and_return(driver)
|
733
|
+
expect(druid.heading6_element).to be_instance_of Druid::Elements::Heading
|
734
|
+
end
|
735
|
+
end
|
736
|
+
end
|
737
|
+
|
738
|
+
describe "paragraph accessors" do
|
739
|
+
context "when called on a page object" do
|
740
|
+
it "should generate accessor methods" do
|
741
|
+
expect(druid).to respond_to(:first_para)
|
742
|
+
expect(druid).to respond_to(:first_para_element)
|
743
|
+
end
|
744
|
+
|
745
|
+
it "should call a block on the element method when present" do
|
746
|
+
expect(block_druid.first_para_element).to eql "p"
|
747
|
+
end
|
748
|
+
end
|
749
|
+
|
750
|
+
context "implementation" do
|
751
|
+
it "should retrieve the text from the p" do
|
752
|
+
expect(driver).to receive(:p).and_return(driver)
|
753
|
+
expect(driver).to receive(:text).and_return("value")
|
754
|
+
expect(druid.first_para).to eql "value"
|
755
|
+
end
|
756
|
+
|
757
|
+
it "should retrieve the element from the page" do
|
758
|
+
expect(driver).to receive(:p).and_return(driver)
|
759
|
+
expect(druid.first_para_element).to be_instance_of Druid::Elements::Paragraph
|
760
|
+
end
|
761
|
+
end
|
762
|
+
end
|
763
|
+
|
764
|
+
describe "file_field accessors" do
|
765
|
+
context "when called on a page object" do
|
766
|
+
it "should geneate accessor methods" do
|
767
|
+
expect(druid).to respond_to(:upload_me=)
|
768
|
+
expect(druid).to respond_to(:upload_me_element)
|
769
|
+
end
|
770
|
+
|
771
|
+
it "should call a block on the element method when present" do
|
772
|
+
expect(block_druid.a_file_element).to eql "file_field"
|
773
|
+
end
|
774
|
+
end
|
775
|
+
|
776
|
+
context "implementation" do
|
777
|
+
it "should set the file name" do
|
778
|
+
expect(driver).to receive(:file_field).and_return(driver)
|
779
|
+
expect(driver).to receive(:set).with('some_file')
|
780
|
+
druid.upload_me = 'some_file'
|
781
|
+
end
|
782
|
+
|
783
|
+
it "should retrieve a file field element" do
|
784
|
+
expect(driver).to receive(:file_field).and_return(driver)
|
785
|
+
expect(druid.upload_me_element).to be_instance_of Druid::Elements::FileField
|
786
|
+
end
|
787
|
+
end
|
788
|
+
end
|
789
|
+
end
|