druid-ts 1.1.3 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +27 -0
  3. data/features/async.feature +6 -0
  4. data/features/div.feature +1 -0
  5. data/features/element.feature +4 -0
  6. data/features/hidden_field.feature +0 -2
  7. data/features/html/async.html +13 -0
  8. data/features/html/multi_elements.html +4 -0
  9. data/features/html/static_elements.html +10 -3
  10. data/features/link.feature +1 -0
  11. data/features/multi_elements.feature +135 -25
  12. data/features/select_list.feature +8 -0
  13. data/features/span.feature +2 -0
  14. data/features/step_definations/async_steps.rb +17 -0
  15. data/features/step_definations/element_steps.rb +6 -0
  16. data/features/step_definations/multi_elements_steps.rb +96 -0
  17. data/features/step_definations/select_list_steps.rb +12 -0
  18. data/features/step_definations/table_steps.rb +20 -3
  19. data/features/support/ajax_test_environment.rb +1 -1
  20. data/features/support/page.rb +7 -2
  21. data/features/table.feature +35 -0
  22. data/features/text_area.feature +0 -2
  23. data/features/text_field.feature +1 -2
  24. data/lib/druid.rb +31 -3
  25. data/lib/druid/accessors.rb +184 -146
  26. data/lib/druid/assist.rb +10 -2
  27. data/lib/druid/element_locators.rb +186 -102
  28. data/lib/druid/elements/div.rb +1 -1
  29. data/lib/druid/elements/element.rb +131 -96
  30. data/lib/druid/elements/hidden_field.rb +1 -5
  31. data/lib/druid/elements/link.rb +1 -1
  32. data/lib/druid/elements/select_list.rb +8 -0
  33. data/lib/druid/elements/span.rb +1 -1
  34. data/lib/druid/elements/table.rb +14 -3
  35. data/lib/druid/elements/table_row.rb +17 -2
  36. data/lib/druid/elements/text_area.rb +0 -8
  37. data/lib/druid/elements/text_field.rb +1 -1
  38. data/lib/druid/javascript/yui.rb +19 -0
  39. data/lib/druid/javascript_framework_facade.rb +3 -1
  40. data/lib/druid/nested_elements.rb +1 -1
  41. data/lib/druid/page_factory.rb +25 -0
  42. data/lib/druid/page_populator.rb +1 -0
  43. data/lib/druid/version.rb +1 -1
  44. data/spec/druid/accessors_spec.rb +189 -1
  45. data/spec/druid/druid_spec.rb +6 -0
  46. data/spec/druid/element_locators_spec.rb +276 -0
  47. data/spec/druid/elements/div_spec.rb +1 -1
  48. data/spec/druid/elements/element_spec.rb +11 -0
  49. data/spec/druid/elements/hidden_field_spec.rb +0 -5
  50. data/spec/druid/elements/link_spec.rb +1 -1
  51. data/spec/druid/elements/span_spec.rb +1 -1
  52. data/spec/druid/elements/text_area_spec.rb +0 -5
  53. data/spec/druid/elements/text_field_spec.rb +1 -1
  54. data/spec/druid/page_factory_spec.rb +20 -0
  55. data/spec/druid/page_populator_spec.rb +8 -4
  56. metadata +2 -1
@@ -65,3 +65,11 @@ Feature: Select List
65
65
  Scenario: It should know if an option is selected
66
66
  When I select "Test 2" from the select list
67
67
  Then the select list should know that "Test 2" is selected
68
+
69
+ Scenario: Clearing multiple select list
70
+ When I clear multiple select list
71
+ Then multiple select list should have no selected options
72
+
73
+ Scenario: Selecting an option by its value
74
+ When I select an option using the value "option2"
75
+ Then the selected option should be "Test 2"
@@ -20,6 +20,8 @@ Feature: Span
20
20
  | index |
21
21
  | name |
22
22
  | text |
23
+ | title |
24
+
23
25
  Scenario: Retrieve a Span
24
26
  When I retrieve a span element
25
27
  Then I should know it exists
@@ -36,6 +36,9 @@ class AsyncPage
36
36
  button(:target, :value => 'Target')
37
37
  button(:hide, :value => 'Hide Button')
38
38
  button(:unhide, :value => 'Unhide Button')
39
+ button(:create_button, :value => "Create Button")
40
+ button(:remove_button, :value => "Remove Button")
41
+ button(:created_button, :value => "New Button")
39
42
  end
40
43
 
41
44
  Given(/^I am on the async elements page$/) do
@@ -61,3 +64,17 @@ Then(/^I should be able to wait until the button becomes invisible$/) do
61
64
  expect(@page.target_element.attribute("block")).to eql "none"
62
65
  end
63
66
  end
67
+
68
+ When(/^I add a button a few seconds from now$/) do
69
+ @page.create_button
70
+ end
71
+
72
+ When(/^I remove a button a few seconds from now$/) do
73
+ @page.created_button_element.when_present
74
+ @page.remove_button
75
+ end
76
+
77
+ Then(/^I should not be able to find the button$/) do
78
+ @page.created_button_element.when_not_present
79
+ expect(@page.created_button_element.exist?).to be false
80
+ end
@@ -103,3 +103,9 @@ end
103
103
  When(/^I retrieve the label element$/) do
104
104
  @element = @page.label_id_element
105
105
  end
106
+
107
+ Then(/^I should be able to flash it$/) do
108
+ sleep 5
109
+ @element.flash
110
+ sleep 5
111
+ end
@@ -306,3 +306,99 @@ end
306
306
  Then(/^the text for label (\d+) should be "([^"]*)"$/) do |label_num, text|
307
307
  expect(@elements[label_num.to_i - 1].text).to eql text
308
308
  end
309
+
310
+ When(/^I select all buttons using no identifier$/) do
311
+ @elements = @page.button_elements
312
+ end
313
+
314
+ When(/^I select all text fields using no identifier$/) do
315
+ @elements = @page.text_field_elements
316
+ end
317
+
318
+ When(/^I select all hidden fields using no identifier$/) do
319
+ @elements = @page.hidden_field_elements
320
+ end
321
+
322
+ When(/^I select all text areas using no identifier$/) do
323
+ @elements = @page.text_area_elements
324
+ end
325
+
326
+ When(/^I select all select lists using no identifier$/) do
327
+ @elements = @page.select_list_elements
328
+ end
329
+
330
+ When(/^I select all links using no identifier$/) do
331
+ @elements = @page.link_elements
332
+ end
333
+
334
+ When(/^I select all checkboxes using no identifier$/) do
335
+ @elements = @page.checkboxes_elements
336
+ end
337
+
338
+ When(/^I select all radio buttons using no identifier$/) do
339
+ @elements = @page.radio_button_elements
340
+ end
341
+
342
+ When(/^I select all divs using no identifier$/) do
343
+ @elements = @page.div_elements
344
+ end
345
+
346
+ When(/^I select all spans using no identifier$/) do
347
+ @elements = @page.span_elements
348
+ end
349
+
350
+ When(/^I select all tables using no identifier$/) do
351
+ @elements = @page.table_elements
352
+ end
353
+
354
+ When(/^I select all cells using no identifier$/) do
355
+ @elements = @page.cell_elements
356
+ end
357
+
358
+ When(/^I select the images using no identifier$/) do
359
+ @elements = @page.image_elements
360
+ end
361
+
362
+ When(/^I select the forms using no identifier$/) do
363
+ @elements = @page.form_elements
364
+ end
365
+
366
+ When(/^I select all list items using no identifier$/) do
367
+ @elements = @page.list_item_elements
368
+ end
369
+
370
+ When(/^I select all unordered lists using no identifier$/) do
371
+ @elements = @page.unordered_list_elements
372
+ end
373
+
374
+ When(/^I select all ordered lists using no identifier$/) do
375
+ @elements = @page.ordered_list_elements
376
+ end
377
+
378
+ When /^I select all h(\d+)s using no identifier$/ do |num|
379
+ @elements = @page.send "h#{num}_elements"
380
+ end
381
+
382
+ When(/^I select all paragraphs using no identifier$/) do
383
+ @elements = @page.paragraph_elements
384
+ end
385
+
386
+ When(/^I select all labels using no identifier$/) do
387
+ @elements = @page.label_elements
388
+ end
389
+
390
+ When(/^I select the file fields with class "([^"]*)"$/) do |class_name|
391
+ @elements = @page.file_field_elements(:class => class_name)
392
+ end
393
+
394
+ Then(/^I should have (\d+) file fields$/) do |num_file_fields|
395
+ expect(@elements.size).to eql num_file_fields.to_i
396
+ end
397
+
398
+ Then(/^the title for file field (\d+) should be "([^"]*)"$/) do |file_field_num, title|
399
+ expect(@elements[file_field_num.to_i - 1].attribute('title')).to eql title
400
+ end
401
+
402
+ When(/^I select all file fields using no identifier$/) do
403
+ @elements = @page.file_field_elements
404
+ end
@@ -69,3 +69,15 @@ Then(/^the value for the option should be "([^"]*)"$/) do |value|
69
69
  @element = @page.send "select_list_#{@how}_element".to_sym
70
70
  expect(@element.value).to eql value
71
71
  end
72
+
73
+ When(/^I clear multiple select list$/) do
74
+ @page.select_list_multiple_element.clear
75
+ end
76
+
77
+ Then(/^multiple select list should have no selected options$/) do
78
+ expect(@page.select_list_multiple_element.selected_options).to be_empty
79
+ end
80
+
81
+ When(/^I select an option using the value "([^"]*)"$/) do |value|
82
+ @page.select_list_id_element.select_value(value)
83
+ end
@@ -7,9 +7,10 @@ When(/^I retrieve a table element by "(.*?)"$/) do |how|
7
7
  end
8
8
 
9
9
  Then(/^the data for row "(.*?)" should be "(.*?)" and "(.*?)"$/) do |row, col1, col2|
10
- row = @element[row.to_i - 1]
11
- expect(row[0].text).to eql col1
12
- expect(row[1].text).to eql col2
10
+ row = (row.to_i - 1) if row.to_i > 0
11
+ table_row = @element[row]
12
+ expect(table_row[0].text).to eql col1
13
+ expect(table_row[1].text).to eql col2
13
14
  end
14
15
 
15
16
  Then(/^the table should have "(.*?)" rows$/) do |number|
@@ -54,3 +55,19 @@ end
54
55
  Then(/^I should see that the table exists$/) do
55
56
  expect(@page.table_id?).to be true
56
57
  end
58
+
59
+ Then(/^the data for column "([^"]*)" and row "([^"]*)" should be "([^"]*)"$/) do |column, row, value|
60
+ expect(@element[row.to_i - 1][column].text).to eql value
61
+ end
62
+
63
+ Then(/^the data for row "([^"]*)" and column "([^"]*)" should be "([^"]*)"$/) do |row, column, value|
64
+ expect(@element[row][column].text).to eql value
65
+ end
66
+
67
+ Then(/^the data for row "([^"]*)" should be nil$/) do |row|
68
+ expect(@element[row]).to be_nil
69
+ end
70
+
71
+ Then(/^the data for row "([^"]*)" and column "([^"]*)" should be nil$/) do |row, column|
72
+ expect(@element[row][column]).to be_nil
73
+ end
@@ -1,4 +1,4 @@
1
- require_relative "../sample-app/sample_app"
1
+ require File.dirname(__FILE__) + "/../sample-app/sample_app"
2
2
 
3
3
  class AjaxTestEnvironment
4
4
  def run
@@ -16,6 +16,7 @@ class Page
16
16
  link(:google_search_link, :link => "Google Search")
17
17
  link(:google_search_link_text, :link_text => "Google Search")
18
18
  link(:google_search_css, :css => "a.link_class")
19
+ link(:google_search_title, :title => "link_title")
19
20
  link(:hello0, {:text => "Hello", :index => 0})
20
21
  link(:hello1, {:text => "Hello", :index => 1})
21
22
  link(:hello2, {:text => "Hello", :index => 2})
@@ -30,6 +31,7 @@ class Page
30
31
  text_field(:text_field_text, :text => "")
31
32
  text_field(:text_field_value, :value => "")
32
33
  text_field(:text_field_title, :title => "text_field_title")
34
+ text_field(:text_field_label, :label => "Text Field")
33
35
  text_field(:text_field_class_index, :class => "text_field_class", :index => 0)
34
36
  text_field(:text_field_name_index, :name => "text_field_name", :index => 0)
35
37
 
@@ -49,6 +51,7 @@ class Page
49
51
  select_list(:select_list_xpath, :xpath => "//select")
50
52
  select_list(:select_list_text, :text => "Test 1")
51
53
  select_list(:select_list_value, :value => "option1")
54
+ select_list(:select_list_multiple, :id => "sel_list_multiple")
52
55
  select_list(:select_list_class_index, :class => "sel_list_class", :index => 0)
53
56
  select_list(:select_list_name_index, :name => "sel_list_name", :index => 0)
54
57
 
@@ -94,6 +97,7 @@ class Page
94
97
  div(:div_index, :index => 0)
95
98
  div(:div_xpath, :xpath => '//div')
96
99
  div(:div_text, :text => "page-object rocks!")
100
+ div(:div_title, :title => "div_title")
97
101
  div(:div_class_index, :class => "div_class", :index => 0)
98
102
  div(:div_name_index, :name => "div_name", :index => 0)
99
103
 
@@ -120,6 +124,7 @@ class Page
120
124
  span(:span_xpath, :xpath => '//span')
121
125
  span(:span_name, :name => 'span_name')
122
126
  span(:span_text, :text => 'My alert')
127
+ span(:span_title, :title => 'span_title')
123
128
  span(:span_class_index, :class => "span_class", :index => 0)
124
129
  span(:span_name_index, :name => "span_name", :index => 0)
125
130
 
@@ -127,8 +132,8 @@ class Page
127
132
  label(:label_name, :name => "label_name")
128
133
  label(:label_class, :class => "label_class")
129
134
  label(:label_text, :text => "page-object is the best!")
130
- label(:label_index, :index => 0)
131
- label(:label_xpath, :xpath => "//label")
135
+ label(:label_index, :index => 1)
136
+ label(:label_xpath, :xpath => "//label[2]")
132
137
  label(:label_class_index, :class => "label_class", :index => 0)
133
138
  label(:label_name_index, :name => "label_name", :index => 0)
134
139
 
@@ -10,6 +10,41 @@ Feature: Table
10
10
  Then I should know it is visible
11
11
  Then I should know it exists
12
12
 
13
+ Scenario: Retrieve data from a table using a row header
14
+ When I retrieve a table element
15
+ Then the data for row "Data3" should be "Data3" and "Data4"
16
+
17
+ Scenario: Retrieve data from a table using a partial row header
18
+ When I retrieve a table element
19
+ Then the data for row "ata3" should be "Data3" and "Data4"
20
+
21
+ Scenario: Retrieve data from a table using a row header in the 2nd column
22
+ When I retrieve a table element
23
+ Then the data for row "Data4" should be "Data3" and "Data4"
24
+
25
+ Scenario: Retrieve data from a table using a partial row header in the 2nd column
26
+ When I retrieve a table element
27
+ Then the data for row "ata4" should be "Data3" and "Data4"
28
+
29
+ Scenario: Retrieve data from a table using a column header
30
+ When I retrieve a table element
31
+ Then the data for column "Data2" and row "2" should be "Data4"
32
+
33
+ Scenario: Retrieve data from a table using a partial column header
34
+ When I retrieve a table element
35
+ Then the data for column "ata2" and row "2" should be "Data4"
36
+
37
+ Scenario: Retrieve data from a table using both headers
38
+ When I retrieve a table element
39
+ Then the data for row "Data3" and column "Data2" should be "Data4"
40
+
41
+ Scenario: Retrieve data from a table with an incorrect row header
42
+ When I retrieve a table element
43
+ Then the data for row "Data20" should be nil
44
+
45
+ Scenario: Retrieve data from a table with an incorrect column header
46
+ When I retrieve a table element
47
+ Then the data for row "Data3" and column "Data20" should be nil
13
48
  @name
14
49
  Scenario Outline: Locating table cells on the Page
15
50
  When I retrieve a table element by "<locate_by>"
@@ -17,8 +17,6 @@ Feature: Text Area
17
17
  | class |
18
18
  | name |
19
19
  | xpath |
20
- | css |
21
- | tag_name |
22
20
  | index |
23
21
 
24
22
  @multi
@@ -20,11 +20,10 @@ Feature: Text Fields
20
20
  | class |
21
21
  | name |
22
22
  | xpath |
23
- | css |
24
- | tag_name |
25
23
  | index |
26
24
  | text |
27
25
  | title |
26
+ | label |
28
27
 
29
28
  Scenario: Retrieve a text field
30
29
  When I retrieve a text field
data/lib/druid.rb CHANGED
@@ -52,8 +52,8 @@ module Druid
52
52
  def initialize(driver, visit=false)
53
53
  if driver.is_a? Watir::Browser
54
54
  @driver ||= driver
55
- initialize_page if respond_to?(:initialize_page)
56
55
  goto if visit && respond_to?(:goto)
56
+ initialize_page if respond_to?(:initialize_page)
57
57
  else
58
58
  raise ArgumentError, "expect Watir::Browser"
59
59
  end
@@ -73,6 +73,34 @@ module Druid
73
73
  driver.goto url
74
74
  end
75
75
 
76
+ #
77
+ # Set the default timeout for page level Waits
78
+ #
79
+ def self.default_page_wait=(timeout)
80
+ @page_wait = timeout
81
+ end
82
+
83
+ #
84
+ # Return the default timeout for page level Waits
85
+ #
86
+ def self.default_page_wait
87
+ @page_wait ||= 30
88
+ end
89
+
90
+ #
91
+ # Sets the default timeout for element level Waits
92
+ #
93
+ def self.default_element_wait=(timeout)
94
+ @element_wait = timeout
95
+ end
96
+
97
+ #
98
+ # Returns the default timeout for element level Waits
99
+ #
100
+ def self.default_element_wait
101
+ @element_wait ||= 5
102
+ end
103
+
76
104
  #
77
105
  # Set the javascript framework to use when determining number of
78
106
  # ajax requests. Valid frameworks are :jquery, :prototype, and :Dojo
@@ -154,7 +182,7 @@ module Druid
154
182
  # @param [String] the message to include with the error if we exceed the timeout duration
155
183
  # @param block the block to execute. It should return true when successful.
156
184
  #
157
- def wait_until(timeout = 30, message = nil, &block)
185
+ def wait_until(timeout = Druid.default_page_wait, message = nil, &block)
158
186
  driver.wait_until(timeout, message, &block)
159
187
  end
160
188
 
@@ -164,7 +192,7 @@ module Druid
164
192
  # @param [Numeric] the amount of time to wait for the block to return true.
165
193
  # @param [String] the message to include with the error if we exceed the timeout duration
166
194
  #
167
- def wait_for_ajax(timeout = 30, message = nil)
195
+ def wait_for_ajax(timeout = Druid.default_page_wait, message = nil)
168
196
  end_time = ::Time.now + timeout
169
197
  until ::Time.now > end_time
170
198
  return if driver.execute_script(Druid::JavascriptFrameworkFacade.pending_requests) == 0
@@ -1,10 +1,11 @@
1
1
  require 'druid/elements'
2
- #
3
- # Contains the class level methods that are inserted into your page class
4
- # when you include the PageObject module. These methods will generate another
5
- # set of methods that provide access to the elements on the web pages.
6
- #
2
+
7
3
  module Druid
4
+ #
5
+ # Contains the class level methods that are inserted into your page class
6
+ # when you include the PageObject module. These methods will generate another
7
+ # set of methods that provide access to the elements on the web pages.
8
+ #
8
9
  module Accessors
9
10
  #
10
11
  # Specify the url for the page. A call to this method will generate a
@@ -34,7 +35,7 @@ module Druid
34
35
  #
35
36
  def expected_title(expected_title)
36
37
  define_method("has_expected_title?") do
37
- has_expected_title = expected_title.kind_of?(Regexp) ? expected_title =~ title : expected_title == title
38
+ has_expected_title = expected_title === title
38
39
  raise "Expected title '#{expected_title}' instead of '#{title}'" unless has_expected_title
39
40
  has_expected_title
40
41
  end
@@ -58,7 +59,9 @@ module Druid
58
59
  end
59
60
 
60
61
  #
61
- # Identify an element as existing within a frame or iframe.
62
+ # Identify an element as existing within a frame or iframe. A frame parameter
63
+ # is passed to the block and must be passed to the other calls to Druid.
64
+ # You can nest calls to in_frame by passing the frame to the next level.
62
65
  #
63
66
  # @example
64
67
  # in_frame(:id => 'frame_id') do |frame|
@@ -69,6 +72,7 @@ module Druid
69
72
  # * :id
70
73
  # * :index
71
74
  # * :name
75
+ # @param frame passed from a previous call to in_frame. Used to nest calls
72
76
  # @param block that contains the calls to elements that exist inside the frame.
73
77
  #
74
78
  def in_frame(identifier, frame=nil, &block)
@@ -77,7 +81,9 @@ module Druid
77
81
  block.call(frame)
78
82
  end
79
83
  #
80
- # Identify an element as existing within a frame or iframe.
84
+ # Identify an element as existing within a frame or iframe. A frame parameter
85
+ # is passed to the block and must be passed to the other calls to Druid.
86
+ # You can nest calls to in_iframe by passing the frame to the next level.
81
87
  #
82
88
  # @example
83
89
  # in_iframe(:id => 'frame_id') do |frame|
@@ -88,6 +94,7 @@ module Druid
88
94
  # * :id
89
95
  # * :index
90
96
  # * :name
97
+ # @param frame passed from a previous call to in_iframe. Used to nest calls
91
98
  # @param block that contains the calls to elements that exist inside the frame.
92
99
  #
93
100
  def in_iframe(identifier, frame=nil, &block)
@@ -105,20 +112,23 @@ module Druid
105
112
  # link(:add_to_cart, :text => "Add to Cart")
106
113
  # # will generate 'add_to_cart', 'add_to_cart_element', and 'add_to_cart?' methods
107
114
  #
108
- # @param the name used for the generated methods
109
- # @param identifier how we find a link. The valid values are:
110
- # :class
111
- # :href
112
- # :id
113
- # :index
114
- # :name
115
- # :text
116
- # :xpath
117
- # :link
118
- # :link_text
119
- # :css
115
+ # @param [Symbol] the name used for the generated methods
116
+ # @param [Hash] identifier how we find a link. You can use a multiple parameters
117
+ # by combining of any of the following except xpath. The valid values are:
118
+ # * :class
119
+ # * :href
120
+ # * :id
121
+ # * :index
122
+ # * :name
123
+ # * :text
124
+ # * :xpath
125
+ # * :link
126
+ # * :link_text
127
+ # * :css
128
+ # * :title
129
+ # @param optional block to be invoked when element method is called
120
130
  #
121
- def link(name, identifier=nil, &block)
131
+ def link(name, identifier={:index => 0}, &block)
122
132
  define_method(name) do
123
133
  return click_link_for identifier.clone unless block_given?
124
134
  self.send("#{name}_element").click
@@ -136,7 +146,7 @@ module Druid
136
146
  end
137
147
 
138
148
  #
139
- # adds four methods to the page object - one to set text in a text field,
149
+ # adds four methods to the page objec - one to set text in a text field,
140
150
  # another to retrieve text from a text field, another to return the text
141
151
  # field element, another to check the text field's existence.
142
152
  #
@@ -145,18 +155,20 @@ module Druid
145
155
  # # will generate 'first_name', 'first_name=', 'first_name_element',
146
156
  # # 'first_name?' methods
147
157
  #
148
- # @param the name used for the generated methods
149
- # @param identifier how we find a text_field. The valid values are:
150
- # :class
151
- # :css
152
- # :id
153
- # :index
154
- # :name
155
- # :tag_name
156
- # :xpath
157
- # :text
158
- # :title
159
- def text_field(name, identifier=nil, &block)
158
+ # @param [Symbol] the name used for the generated methods
159
+ # @param [Hash] identifier how we find a text_field. You can use a multiple parameters
160
+ # by combining of any of the following except xpath. The valid values are:
161
+ # * :class
162
+ # * :id
163
+ # * :index
164
+ # * :name
165
+ # * :xpath
166
+ # * :text
167
+ # * :title
168
+ # * :label
169
+ # @param optional block to be invoked when element method is called
170
+ #
171
+ def text_field(name, identifier={:index => 0}, &block)
160
172
  define_method(name) do
161
173
  return text_field_value_for identifier.clone unless block_given?
162
174
  self.send("#{name}_element").value
@@ -188,16 +200,18 @@ module Druid
188
200
  # # will generate 'check_active', 'uncheck_active', 'active_checked?',
189
201
  # # 'active_element', and 'active?' methods
190
202
  #
191
- # @param the name used for the generated methods
192
- # @param identifier how we find a checkbox. The valid values are:
193
- # :class
194
- # :id
195
- # :index
196
- # :name
197
- # :xpath
198
- # :value
203
+ # @param [Symbol] the name used for the generated methods
204
+ # @param [Hash] identifier how we find a checkbox. You can use a multiple parameters
205
+ # by combining of any of the following except xpath. The valid values are:
206
+ # * :class
207
+ # * :id
208
+ # * :index
209
+ # * :name
210
+ # * :xpath
211
+ # * :value
212
+ # @param optional block to be invoked when element method is called
199
213
  #
200
- def checkbox(name, identifier=nil, &block)
214
+ def checkbox(name, identifier={:index => 0}, &block)
201
215
  define_method("check_#{name}") do
202
216
  return check_checkbox identifier.clone unless block_given?
203
217
  self.send("#{name}_element").check
@@ -232,15 +246,17 @@ module Druid
232
246
  # select_list(:state, :id => "state")
233
247
  # # will generate 'state', 'state=', 'state_element', 'state?' methods
234
248
  #
235
- # @param the name used for the generated methods
236
- # @param identifier how we find a select_list. The valid values are:
249
+ # @param [Symbol] the name used for the generated methods
250
+ # @param [Hash] identifier how we find a select_list. You can use a multiple parameters
251
+ # by combining of any of the following except xpath. The valid values are:
237
252
  # :class
238
253
  # :id
239
254
  # :index
240
255
  # :name
241
256
  # :xpath
257
+ # @param optional block to be invoked when element method is called
242
258
  #
243
- def select_list(name, identifier=nil, &block)
259
+ def select_list(name, identifier={:index => 0}, &block)
244
260
  define_method(name) do
245
261
  return select_list_value_for identifier.clone unless block_given?
246
262
  self.send("#{name}_element").options.each {|o| return o.text if o.selected?}
@@ -273,16 +289,18 @@ module Druid
273
289
  # # will generate 'select_north', 'clear_north', 'north_selected?',
274
290
  # # 'north_element', and 'north?' methods
275
291
  #
276
- # @param the name used for the generated methods
277
- # @param identifier how we find a radio_button. The valid values are:
278
- # :class
279
- # :id
280
- # :index
281
- # :name
282
- # :xpath
283
- # :value
292
+ # @param [Symbol] the name used for the generated methods
293
+ # @param [Hash] identifier how we find a radio_button. You can use a multiple parameters
294
+ # by combining of any of the following except xpath. The valid values are:
295
+ # * :class
296
+ # * :id
297
+ # * :index
298
+ # * :name
299
+ # * :xpath
300
+ # * :value
301
+ # @param optional block to be invoked when element method is called
284
302
  #
285
- def radio_button(name, identifier=nil, &block)
303
+ def radio_button(name, identifier={:index => 0}, &block)
286
304
  define_method("select_#{name}") do
287
305
  return select_radio identifier.clone unless block_given?
288
306
  self.send("#{name}_element").select
@@ -315,8 +333,9 @@ module Druid
315
333
  # button(:purchase, :id => 'purchase')
316
334
  # # will generate 'purchase', 'purchase_element', and 'purchase?' methods
317
335
  #
318
- # @param the name used for the generated methods
319
- # @param identifier how we find a button. The valid values are:
336
+ # @param [Symbol] the name used for the generated methods
337
+ # @param [Hash] identifier how we find a button. You can use a multiple parameters
338
+ # by combining of any of the following except xpath. The valid values are:
320
339
  # :class
321
340
  # :id
322
341
  # :index
@@ -326,8 +345,9 @@ module Druid
326
345
  # :src
327
346
  # :alt
328
347
  # :css
348
+ # @param optional block to be invoked when element method is called
329
349
  #
330
- def button(name, identifier=nil, &block)
350
+ def button(name, identifier={:index => 0}, &block)
331
351
  define_method(name) do
332
352
  return click_button_for identifier.clone unless block_given?
333
353
  self.send("#{name}_element").click
@@ -352,17 +372,20 @@ module Druid
352
372
  # div(:message, :id => 'message')
353
373
  # # will generate 'message', 'message_element', and 'message?' methods
354
374
  #
355
- # @param the name used for the generated methods
356
- # @param identifier how we find a div. The valid values are:
357
- # :class
358
- # :id
359
- # :index
360
- # :xpath
361
- # :name
362
- # :text
363
- # :value
375
+ # @param [Symbol] the name used for the generated methods
376
+ # @param [Hash] identifier how we find a div. You can use a multiple parameters
377
+ # by combining of any of the following except xpath. The valid values are:
378
+ # * :class
379
+ # * :id
380
+ # * :index
381
+ # * :xpath
382
+ # * :name
383
+ # * :text
384
+ # * :value
385
+ # * :title
386
+ # @param optional block to be invoked when element method is called
364
387
  #
365
- def div(name, identifier=nil, &block)
388
+ def div(name, identifier={:index => 0}, &block)
366
389
  define_method(name) do
367
390
  return div_text_for identifier.clone unless block_given?
368
391
  self.send("#{name}_element").text
@@ -388,14 +411,16 @@ module Druid
388
411
  # # will generate a 'cart_element' and 'cart?' method
389
412
  #
390
413
  # @param the name used for the generated methods
391
- # @param identifier how we find a table. The valid values are:
392
- # :class
393
- # :id
394
- # :index
395
- # :xpath
396
- # :name
414
+ # @param identifier how we find a table. You can use a multiple parameters
415
+ # by combining of any of the following except xpath. The valid values are:
416
+ # * :class
417
+ # * :id
418
+ # * :index
419
+ # * :xpath
420
+ # * :name
421
+ # @param optional block to be invoked when element method is called
397
422
  #
398
- def table(name, identifier=nil, &block)
423
+ def table(name, identifier={:index => 0}, &block)
399
424
  define_method("#{name}_element") do
400
425
  return call_block(&block) if block_given?
401
426
  table_for(identifier.clone)
@@ -417,16 +442,18 @@ module Druid
417
442
  # cell(:total, :id => 'total_cell')
418
443
  # # will generate 'total', 'total_element', and 'total?' methods
419
444
  #
420
- # @param the name used for the generated methods
421
- # @param identifier how we find a cell. The valid values are:
422
- # :class
423
- # :id
424
- # :index
425
- # :xpath
426
- # :name
427
- # :text
445
+ # @param [Symbol] the name used for the generated methods
446
+ # @param [Hash] identifier how we find a cell. You can use a multiple parameters
447
+ # by combining of any of the following except xpath. The valid values are:
448
+ # * :class
449
+ # * :id
450
+ # * :index
451
+ # * :xpath
452
+ # * :name
453
+ # * :text
454
+ # @param optional block to be invoked when element method is called
428
455
  #
429
- def cell(name, identifier=nil, &block)
456
+ def cell(name, identifier={:index => 0}, &block)
430
457
  define_method(name) do
431
458
  return cell_text_for identifier.clone unless block_given?
432
459
  self.send("#{name}_element").text
@@ -451,16 +478,18 @@ module Druid
451
478
  # span(:alert, :id => 'alert')
452
479
  # # will generate 'alert', 'alert_element', and 'alert?' methods
453
480
  #
454
- # @param the name used for the generated methods
455
- # @param identifier how we find a span. The valid values are:
456
- # :class
457
- # :id
458
- # :index
459
- # :xpath
460
- # :name
461
- # :text
481
+ # @param [Symbol] the name used for the generated methods
482
+ # @param [Hash] identifier how we find a span. You can use a multiple parameters
483
+ # by combining of any of the following except xpath. The valid values are:
484
+ # * :class
485
+ # * :id
486
+ # * :index
487
+ # * :xpath
488
+ # * :name
489
+ # * :text
490
+ # @param optional block to be invoked when element method is called
462
491
  #
463
- def span(name, identifier=nil, &block)
492
+ def span(name, identifier={:index => 0}, &block)
464
493
  define_method(name) do
465
494
  return span_text_for identifier.clone unless block_given?
466
495
  self.send("#{name}_element").text
@@ -485,17 +514,19 @@ module Druid
485
514
  # image(:logo, :id => 'logo')
486
515
  # # will generate 'logo_element' and 'logo?' methods
487
516
  #
488
- # @param the name used for the generated methods
489
- # @param identifier how we find a image. The valid values are:
490
- # :class
491
- # :id
492
- # :index
493
- # :name
494
- # :xpath
495
- # :alt
496
- # :src
517
+ # @param [Symbol] the name used for the generated methods
518
+ # @param [Hash] identifier how we find a image. You can use a multiple parameters
519
+ # by combining of any of the following except xpath. The valid values are:
520
+ # * :class
521
+ # * :id
522
+ # * :index
523
+ # * :name
524
+ # * :xpath
525
+ # * :alt
526
+ # * :src
527
+ # @param optional block to be invoked when element method is called
497
528
  #
498
- def image(name, identifier=nil, &block)
529
+ def image(name, identifier={:index => 0}, &block)
499
530
  define_method("#{name}_element") do
500
531
  return call_block(&block) if block_given?
501
532
  image_for(identifier.clone)
@@ -516,16 +547,18 @@ module Druid
516
547
  # form(:login, :id => 'login')
517
548
  # # will generate 'login_element' and 'login?' methods
518
549
  #
519
- # @param [String] the name used for the generated methods
520
- # @param [Hash] identifier how we find a form. The valid keys are:
550
+ # @param [Symbol] the name used for the generated methods
551
+ # @param [Hash] identifier how we find a form. You can use a multiple parameters
552
+ # by combining of any of the following except xpath. The valid keys are:
521
553
  # * :class
522
554
  # * :id
523
555
  # * :index
524
556
  # * :xpath
525
557
  # * :name
526
558
  # * :action
559
+ # @param optional block to be invoked when element method is called
527
560
  #
528
- def form(name, identifier=nil, &block)
561
+ def form(name, identifier={:index => 0}, &block)
529
562
  define_method("#{name}_element") do
530
563
  return call_block(&block) if block_given?
531
564
  form_for(identifier.clone)
@@ -547,19 +580,19 @@ module Druid
547
580
  # hidden_field(:user_id, :id => "user_identity")
548
581
  # # will generate 'user_id', 'user_id_element' and 'user_id?' methods
549
582
  #
550
- # @param [String] the name used for the generated methods
551
- # @param [Hash] identifier how we find a hidden field. The valid keys are:
583
+ # @param [Symbol] the name used for the generated methods
584
+ # @param [Hash] identifier how we find a hidden field. You can use a multiple parameters
585
+ # by combining of any of the following except xpath. The valid keys are:
552
586
  # * :class
553
- # * :css
554
587
  # * :id
555
588
  # * :index
556
589
  # * :name
557
- # * :tag_name
558
590
  # * :text
559
591
  # * :xpath
560
592
  # * :value
593
+ # @param optional block to be invoked when element method is called
561
594
  #
562
- def hidden_field(name, identifier=nil, &block)
595
+ def hidden_field(name, identifier={:index => 0}, &block)
563
596
  define_method("#{name}_element") do
564
597
  return call_block(&block) if block_given?
565
598
  hidden_field_for(identifier.clone)
@@ -585,15 +618,17 @@ module Druid
585
618
  # list_item(:item_one, :id => 'one')
586
619
  # # will generate 'item_one', 'item_one_element', and 'item_one?' methods
587
620
  #
588
- # @param [String] the name used for the generated methods
589
- # @param [Hash] identifier how we find a list item. The valid keys are:
621
+ # @param [Symbol] the name used for the generated methods
622
+ # @param [Hash] identifier how we find a list item. You can use a multiple parameters
623
+ # by combining of any of the following except xpath. The valid keys are:
590
624
  # * :class
591
625
  # * :id
592
626
  # * :index
593
627
  # * :xpath
594
628
  # * :name
629
+ # @param optional block to be invoked when element method is called
595
630
  #
596
- def list_item(name, identifier=nil, &block)
631
+ def list_item(name, identifier={:index => 0}, &block)
597
632
  define_method(name) do
598
633
  return list_item_text_for identifier.clone unless block_given?
599
634
  self.send("#{name}_element").text
@@ -618,15 +653,17 @@ module Druid
618
653
  # ordered_list(:top_five, :id => 'top')
619
654
  # # will generate 'top_five_element' and 'top_five?' methods
620
655
  #
621
- # @param [String] the name used for the generated methods
622
- # @param [Hash] identifier how we find an ordered list. The valid keys are:
656
+ # @param [Symbol] the name used for the generated methods
657
+ # @param [Hash] identifier how we find an ordered list. You can use a multiple parameters
658
+ # by combining of any of the following except xpath. The valid keys are:
623
659
  # * :class
624
660
  # * :id
625
661
  # * :index
626
662
  # * :xpath
627
663
  # * :name
664
+ # @param optional block to be invoked when element method is called
628
665
  #
629
- def ordered_list(name, identifier=nil, &block)
666
+ def ordered_list(name, identifier={:index => 0}, &block)
630
667
  define_method("#{name}_element") do
631
668
  return call_block(&block) if block_given?
632
669
  ordered_list_for(identifier.clone)
@@ -649,17 +686,17 @@ module Druid
649
686
  # # will generate 'address', 'address=', 'address_element',
650
687
  # # 'address?' methods
651
688
  #
652
- # @param [String] the name used for the generated methods
653
- # @param [Hash] identifier how we find a text area. The valid keys are:
689
+ # @param [Symbol] the name used for the generated methods
690
+ # @param [Hash] identifier how we find a text area. You can use a multiple parameters
691
+ # by combining of any of the following except xpath. The valid keys are:
654
692
  # * :class
655
- # * :css
656
693
  # * :id
657
694
  # * :index
658
695
  # * :name
659
- # * :tag_name
660
696
  # * :xpath
697
+ # @param optional block to be invoked when element method is called
661
698
  #
662
- def text_area(name, identifier=nil, &block)
699
+ def text_area(name, identifier={:index => 0}, &block)
663
700
  define_method("#{name}=") do |value|
664
701
  return text_area_value_set(identifier.clone, value) unless block_given?
665
702
  self.send("#{name}_element").value = value
@@ -688,15 +725,16 @@ module Druid
688
725
  # unordered_list(:menu, :id => 'main_menu')
689
726
  # # will generate 'menu_element' and 'menu?' methods
690
727
  #
691
- # @param [String] the name used for the generated methods
692
- # @param [Hash] identifier how we find an unordered list. The valid keys are:
728
+ # @param [Symbol] the name used for the generated methods
729
+ # @param [Hash] identifier how we find an unordered list. You can use a multiple parameters
730
+ # by combining of any of the following except xpath. The valid keys are:
693
731
  # * :class
694
732
  # * :id
695
733
  # * :index
696
734
  # * :xpath
697
735
  # * :name
698
- #
699
- def unordered_list(name, identifier=nil, &block)
736
+ # @param optional block to be invoked when element method is called
737
+ def unordered_list(name, identifier={:index => 0}, &block)
700
738
  define_method("#{name}_element") do
701
739
  return call_block(&block) if block_given?
702
740
  unordered_list_for(identifier.clone)
@@ -717,7 +755,7 @@ module Druid
717
755
  # h1(:title, :id => 'title')
718
756
  # # will generate 'title', 'title_element', and 'title?' methods
719
757
  #
720
- # @param [String] the name used for the generated methods
758
+ # @param [Symbol] the name used for the generated methods
721
759
  # @param [Hash] identifier how we find a H1. You can use a multiple paramaters
722
760
  # by combining of any of the following except xpath. The valid keys are:
723
761
  # * :class
@@ -727,7 +765,7 @@ module Druid
727
765
  # * :xpath
728
766
  # @param optional block to be invoked when element method is called
729
767
  #
730
- def h1(name, identifier=nil, &block)
768
+ def h1(name, identifier={:index => 0}, &block)
731
769
  define_method(name) do
732
770
  return h1_text_for identifier.clone unless block_given?
733
771
  self.send("#{name}_element").text
@@ -751,7 +789,7 @@ module Druid
751
789
  # h2(:title, :id => 'title')
752
790
  # # will generate 'title', 'title_element', and 'title?' methods
753
791
  #
754
- # @param [String] the name used for the generated methods
792
+ # @param [Symbol] the name used for the generated methods
755
793
  # @param [Hash] identifier how we find a H2. You can use a multiple paramaters
756
794
  # by combining of any of the following except xpath. The valid keys are:
757
795
  # * :class
@@ -761,7 +799,7 @@ module Druid
761
799
  # * :xpath
762
800
  # @param optional block to be invoked when element method is called
763
801
  #
764
- def h2(name, identifier=nil, &block)
802
+ def h2(name, identifier={:index => 0}, &block)
765
803
  define_method(name) do
766
804
  return h2_text_for identifier.clone unless block_given?
767
805
  self.send("#{name}_element").text
@@ -785,7 +823,7 @@ module Druid
785
823
  # h3(:title, :id => 'title')
786
824
  # # will generate 'title', 'title_element', and 'title?' methods
787
825
  #
788
- # @param [String] the name used for the generated methods
826
+ # @param [Symbol] the name used for the generated methods
789
827
  # @param [Hash] identifier how we find a H3. You can use a multiple paramaters
790
828
  # by combining of any of the following except xpath. The valid keys are:
791
829
  # * :class
@@ -795,7 +833,7 @@ module Druid
795
833
  # * :xpath
796
834
  # @param optional block to be invoked when element method is called
797
835
  #
798
- def h3(name, identifier=nil, &block)
836
+ def h3(name, identifier={:index => 0}, &block)
799
837
  define_method(name) do
800
838
  return h3_text_for identifier.clone unless block_given?
801
839
  self.send("#{name}_element").text
@@ -819,7 +857,7 @@ module Druid
819
857
  # h4(:title, :id => 'title')
820
858
  # # will generate 'title', 'title_element', and 'title?' methods
821
859
  #
822
- # @param [String] the name used for the generated methods
860
+ # @param [Symbol] the name used for the generated methods
823
861
  # @param [Hash] identifier how we find a H4. You can use a multiple paramaters
824
862
  # by combining of any of the following except xpath. The valid keys are:
825
863
  # * :class
@@ -829,7 +867,7 @@ module Druid
829
867
  # * :xpath
830
868
  # @param optional block to be invoked when element method is called
831
869
  #
832
- def h4(name, identifier=nil, &block)
870
+ def h4(name, identifier={:index => 0}, &block)
833
871
  define_method(name) do
834
872
  return h4_text_for identifier.clone unless block_given?
835
873
  self.send("#{name}_element").text
@@ -853,7 +891,7 @@ module Druid
853
891
  # h5(:title, :id => 'title')
854
892
  # # will generate 'title', 'title_element', and 'title?' methods
855
893
  #
856
- # @param [String] the name used for the generated methods
894
+ # @param [Symbol] the name used for the generated methods
857
895
  # @param [Hash] identifier how we find a H5. You can use a multiple paramaters
858
896
  # by combining of any of the following except xpath. The valid keys are:
859
897
  # * :class
@@ -863,7 +901,7 @@ module Druid
863
901
  # * :xpath
864
902
  # @param optional block to be invoked when element method is called
865
903
  #
866
- def h5(name, identifier=nil, &block)
904
+ def h5(name, identifier={:index => 0}, &block)
867
905
  define_method(name) do
868
906
  return h5_text_for identifier.clone unless block_given?
869
907
  self.send("#{name}_element").text
@@ -887,7 +925,7 @@ module Druid
887
925
  # h6(:title, :id => 'title')
888
926
  # # will generate 'title', 'title_element', and 'title?' methods
889
927
  #
890
- # @param [String] the name used for the generated methods
928
+ # @param [Symbol] the name used for the generated methods
891
929
  # @param [Hash] identifier how we find a H6. You can use a multiple paramaters
892
930
  # by combining of any of the following except xpath. The valid keys are:
893
931
  # * :class
@@ -897,7 +935,7 @@ module Druid
897
935
  # * :xpath
898
936
  # @param optional block to be invoked when element method is called
899
937
  #
900
- def h6(name, identifier=nil, &block)
938
+ def h6(name, identifier={:index => 0}, &block)
901
939
  define_method(name) do
902
940
  return h6_text_for identifier.clone unless block_given?
903
941
  self.send("#{name}_element").text
@@ -921,7 +959,7 @@ module Druid
921
959
  # paragraph(:title, :id => 'title')
922
960
  # # will generate 'title', 'title_element', and 'title?' methods
923
961
  #
924
- # @param [String] the name used for the generated methods
962
+ # @param [Symbol] the name used for the generated methods
925
963
  # @param [Hash] identifier how we find a paragraph. You can use a multiple paramaters
926
964
  # by combining of any of the following except xpath. The valid keys are:
927
965
  # * :class
@@ -931,7 +969,7 @@ module Druid
931
969
  # * :xpath
932
970
  # @param optional block to be invoked when element method is called
933
971
  #
934
- def paragraph(name, identifier=nil, &block)
972
+ def paragraph(name, identifier={:index => 0}, &block)
935
973
  define_method(name) do
936
974
  return paragraph_text_for identifier.clone unless block_given?
937
975
  self.send("#{name}_element").text
@@ -955,7 +993,7 @@ module Druid
955
993
  # file_field(:the_file, :id => 'file_to_upload')
956
994
  # # will generate 'the_file=', 'the_file_element', and 'the_file?' methods
957
995
  #
958
- # @param [String] the name used for the generated methods
996
+ # @param [Symbol] the name used for the generated methods
959
997
  # @param [Hash] identifier how we find a file_field. You can use a multiple paramaters
960
998
  # by combining of any of the following except xpath. The valid keys are:
961
999
  # * :class
@@ -966,7 +1004,7 @@ module Druid
966
1004
  # * :xpath
967
1005
  # @param optional block to be invoked when element method is called
968
1006
  #
969
- def file_field(name, identifier=nil, &block)
1007
+ def file_field(name, identifier={:index => 0}, &block)
970
1008
  define_method("#{name}=") do |value|
971
1009
  return file_field_value_set(identifier.clone, value) unless block_given?
972
1010
  self.send("#{name}_element").value = value
@@ -989,7 +1027,7 @@ module Druid
989
1027
  # label(:message, :id => 'message')
990
1028
  # # will generate 'message', 'message_element', and 'message?' methods
991
1029
  #
992
- # @param [String] the name used for the generated methods
1030
+ # @param [Symbol] the name used for the generated methods
993
1031
  # @param [Hash] identifier how we find a label. You can use a multiple parameters
994
1032
  # by combining of any of the following except xpath. The valid keys are:
995
1033
  # * :class
@@ -1000,7 +1038,7 @@ module Druid
1000
1038
  # * :xpath
1001
1039
  # @param optional block to be invoked when element method is called
1002
1040
  #
1003
- def label(name, identifier=nil, &block)
1041
+ def label(name, identifier={:index => 0}, &block)
1004
1042
  define_method(name) do
1005
1043
  return label_text_for identifier.clone unless block_given?
1006
1044
  self.send("#{name}_element").text
@@ -1024,7 +1062,7 @@ module Druid
1024
1062
  # element(:titile, :id => 'title')
1025
1063
  # # will generate 'title'm 'title_element', and 'title?' methods
1026
1064
  #
1027
- # @param [String] the name used for the generated methods
1065
+ # @param [Symbol] the name used for the generated methods
1028
1066
  # @param [Hash] identifier how we find an element. You can use a multiple parameters
1029
1067
  # by combining of any of the following except xpath. The valid keys are:
1030
1068
  # * :class
@@ -1034,7 +1072,7 @@ module Druid
1034
1072
  # * :xpath
1035
1073
  # @param optional block to be invoked when element method is called
1036
1074
  #
1037
- def element(name, tag, identifier=nil, &block)
1075
+ def element(name, tag, identifier={:index => 0}, &block)
1038
1076
  define_method("#{name}") do
1039
1077
  self.send("#{name}_element").text
1040
1078
  end