page-object 0.5.1 → 0.5.2

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.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm 1.9.2-p290@page-object --create
1
+ rvm 1.9.3-p0@page-object --create
data/ChangeLog CHANGED
@@ -1,4 +1,12 @@
1
- === Version 0.5.1 / 2011-11-16
1
+ === Version 0.5.2 / 2011-11-30
2
+ * Enhancements
3
+ * Added ability to find image buttons by src
4
+ * Added ability to find image button by alt
5
+ * Added first_row and last_row methods to Table
6
+ * Updated to use selenium-webdriver 2.14.0
7
+ * Updated to use watir-webdriver 0.3.9
8
+
9
+ === Version 0.5.1 / 2011-11-18
2
10
  * Enhancements
3
11
  * Added instance level in_frame method
4
12
  * Support for nesting all *_element instance methods inside in_frame call
@@ -6,9 +6,21 @@ Feature: Button
6
6
  Background:
7
7
  Given I am on the static elements page
8
8
 
9
- Scenario: Getting the text from a div
9
+ Scenario: Clicking a button (type=submit)
10
10
  When I click the button
11
11
  Then I should be on the success page
12
+
13
+ Scenario: Clicking a button (type=image)
14
+ When I click the button with type image
15
+ Then I should be on the success page
16
+
17
+ Scenario: Clicking an image button by src
18
+ When I click the image button using src
19
+ Then I should be on the success page
20
+
21
+ Scenario: Clicking an image button by alt
22
+ When I click the image button using alt
23
+ Then I should be on the success page
12
24
 
13
25
  Scenario: Retrieve a button element
14
26
  When I retrieve a button element
@@ -9,6 +9,12 @@ Feature: Elements
9
9
  When I clear the text field
10
10
  Then the text field should contain ""
11
11
 
12
+ Scenario: Elements enabled?
13
+ When I check an enabled button
14
+ Then it should know it is enabled
15
+ When I check a disabled button
16
+ Then it should know it is not enabled
17
+
12
18
  Scenario: Link element methods
13
19
  When I retrieve a link element
14
20
  Then I should know it exists
Binary file
@@ -46,8 +46,10 @@
46
46
  </table>
47
47
 
48
48
  <form method="get" action="success.html">
49
- <input id='button_id' name='button_name' class='button_class' type="submit" value="Click Me">
49
+ <input id='button_id' name='button_name' class='button_class' type="submit" value="Click Me"/>
50
+ <input id='button_image_id' type='image' src='images/submit.gif' alt='Submit'/>
50
51
  <button type='button' id='btn_id' name='btn_name' class='btn_class'>Click Me Too</button>
52
+ <input value="Disabled" disabled="true" type ="submit"/>
51
53
  </form>
52
54
 
53
55
  <img src="images/circle.png" id="image_id" name="image_name" class="image_class">
@@ -2,6 +2,18 @@ When /^I click the button$/ do
2
2
  @page.button_id
3
3
  end
4
4
 
5
+ When /^I click the button with type image$/ do
6
+ @page.button_image_id
7
+ end
8
+
9
+ When /^I click the image button using src$/ do
10
+ @page.button_image_src
11
+ end
12
+
13
+ When /^I click the image button using alt$/ do
14
+ @page.button_image_alt
15
+ end
16
+
5
17
  When /^I search for the button by "([^\"]*)"$/ do |how|
6
18
  @how = how
7
19
  end
@@ -107,3 +107,19 @@ end
107
107
  When /^I clear the text field$/ do
108
108
  @page.text_field_id_element.clear
109
109
  end
110
+
111
+ When /^I check an enabled button$/ do
112
+ @element = @page.button_id_element
113
+ end
114
+
115
+ Then /^it should know it is enabled$/ do
116
+ @element.should be_enabled
117
+ end
118
+
119
+ When /^I check a disabled button$/ do
120
+ @element = @page.disabled_button_element
121
+ end
122
+
123
+ Then /^it should know it is not enabled$/ do
124
+ @element.should_not be_enabled
125
+ end
@@ -1,4 +1,4 @@
1
- Then /^the data for row "([^"]*)" should be "([^"]*)" and "([^"]*)"$/ do |row, col1, col2|
1
+ Then /^the data for row "([^\"]*)" should be "([^\"]*)" and "([^\"]*)"$/ do |row, col1, col2|
2
2
  table_row = @element[row.to_i - 1]
3
3
  table_row[0].text.should == col1
4
4
  table_row[1].text.should == col2
@@ -17,10 +17,20 @@ When /^I retrieve a table element by "([^\"]*)"$/ do |how|
17
17
  @element = @page.send "table_#{how}_element"
18
18
  end
19
19
 
20
- When /^I retrieve a table element by "([^"]*)" and "([^"]*)"$/ do |param1, param2|
20
+ When /^I retrieve a table element by "([^\"]*)" and "([^\"]*)"$/ do |param1, param2|
21
21
  @element = @page.send "table_#{param1}_#{param2}_element"
22
22
  end
23
23
 
24
24
  When /^I retrieve a table element while the script is executing$/ do
25
25
  @element = @page.table_element(:id => 'table_id')
26
26
  end
27
+
28
+ Then /^the data for the first row should be "([^\"]*)" and "([^\"]*)"$/ do |col1, col2|
29
+ @element.first_row[0].text.should == col1
30
+ @element.first_row[1].text.should == col2
31
+ end
32
+
33
+ Then /^the data for the last row should be "([^\"]*)" and "([^\"]*)"$/ do |col1, col2|
34
+ @element.last_row[0].text.should == col1
35
+ @element.last_row[1].text.should == col2
36
+ end
@@ -125,6 +125,10 @@ class Page
125
125
  button(:button_class_index, :class => "button_class", :index => 0)
126
126
  button(:button_name_index, :name => "button_name", :index => 0)
127
127
 
128
+ button(:button_image_id, :id => 'button_image_id')
129
+ button(:button_image_src, :src => 'images/submit.gif')
130
+ button(:button_image_alt, :alt => 'Submit')
131
+
128
132
  button(:btn_id, :id => 'btn_id')
129
133
  button(:btn_name, :name => 'btn_name')
130
134
  button(:btn_class, :class => 'btn_class')
@@ -134,6 +138,8 @@ class Page
134
138
  button(:btn_class_index, :class => "btn_class", :index => 0)
135
139
  button(:btn_name_index, :name => "btn_name", :index => 0)
136
140
 
141
+ button(:disabled_button, :value => 'Disabled')
142
+
137
143
  image(:image_id, :id => 'image_id')
138
144
  image(:image_name, :name => 'image_name')
139
145
  image(:image_class, :class => 'image_class')
@@ -23,6 +23,8 @@ Feature: Table
23
23
  And each row should contain "Data"
24
24
  And row "1" should have "2" columns
25
25
  And each column should contain "Data"
26
+ And the data for the first row should be "Data1" and "Data2"
27
+ And the data for the last row should be "Data3" and "Data4"
26
28
 
27
29
  Scenario Outline: Locating table cells on the Page
28
30
  When I retrieve a table element by "<search_by>"
@@ -323,6 +323,8 @@ module PageObject
323
323
  # * :text => Watir and Selenium
324
324
  # * :value => Watir and Selenium
325
325
  # * :xpath => Watir and Selenium
326
+ # * :src => Watir and Selenium (input type=image only)
327
+ # * :alt => Watir and Selenium (input type=image only)
326
328
  # @param optional block to be invoked when element method is called
327
329
  #
328
330
  def button(name, identifier=nil, &block)
@@ -11,11 +11,11 @@ module PageObject
11
11
  protected
12
12
 
13
13
  def self.watir_finders
14
- super + [:text, :value]
14
+ super + [:text, :value, :src, :alt]
15
15
  end
16
16
 
17
17
  def self.selenium_finders
18
- super + [:value]
18
+ super + [:value, :src, :alt]
19
19
  end
20
20
 
21
21
  def include_platform_for platform
@@ -20,6 +20,24 @@ module PageObject
20
20
  end
21
21
  end
22
22
 
23
+ #
24
+ # return the first row
25
+ #
26
+ # @return PageObject::Elements::TableRow
27
+ #
28
+ def first_row
29
+ self[0]
30
+ end
31
+
32
+ #
33
+ # return the last row
34
+ #
35
+ # @return PageObject::Elements::TableRow
36
+ #
37
+ def last_row
38
+ self[-1]
39
+ end
40
+
23
41
  protected
24
42
 
25
43
  def child_xpath
@@ -462,6 +462,7 @@ module PageObject
462
462
  #
463
463
  def click_button_for(identifier)
464
464
  how, what, frame_identifiers = parse_identifiers(identifier, Elements::Button, 'input', :type => 'submit')
465
+ puts "how=#{how}, what=#{what}"
465
466
  switch_to_frame(frame_identifiers)
466
467
  @browser.find_element(how, what).click
467
468
  @browser.switch_to.default_content unless frame_identifiers.nil?
@@ -781,6 +782,8 @@ module PageObject
781
782
  return false if identifier[:href] and tag == 'a'
782
783
  return false if identifier[:text] and ['div', 'span', 'td'].include? tag
783
784
  return false if identifier[:value] and tag == 'input' and additional[:type] == 'submit'
785
+ return false if identifier[:src] and tag == 'input' and additional[:type] == 'submit'
786
+ return false if identifier[:alt] and tag == 'input' and additional[:type] == 'submit'
784
787
  return false if identifier[:value] and tag == 'input' and additional[:type] == 'radio'
785
788
  true
786
789
  end
@@ -1,4 +1,4 @@
1
1
  module PageObject
2
2
  # @private
3
- VERSION = "0.5.1"
3
+ VERSION = "0.5.2"
4
4
  end
data/page-object.gemspec CHANGED
@@ -20,7 +20,7 @@ Gem::Specification.new do |s|
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
  s.add_dependency 'watir-webdriver', '>= 0.3.9'
23
- s.add_dependency 'selenium-webdriver', '>= 2.12.2'
23
+ s.add_dependency 'selenium-webdriver', '>= 2.14.0'
24
24
 
25
25
  s.add_development_dependency 'rspec', '>= 2.6.0'
26
26
  s.add_development_dependency 'cucumber', '>= 1.1.0'
@@ -6,14 +6,14 @@ describe PageObject::Elements::Button do
6
6
 
7
7
  context "when mapping how to find an element" do
8
8
  it "should map watir types to same" do
9
- [:class, :id, :index, :name, :value, :xpath].each do |t|
9
+ [:class, :id, :index, :name, :value, :xpath, :src, :alt].each do |t|
10
10
  identifier = button.watir_identifier_for t => 'value'
11
11
  identifier.keys.first.should == t
12
12
  end
13
13
  end
14
14
 
15
15
  it "should map selenium types to same" do
16
- [:class, :id, :index, :name, :value, :xpath].each do |t|
16
+ [:class, :id, :index, :name, :value, :xpath, :src, :alt].each do |t|
17
17
  key, value = button.selenium_identifier_for t => 'value'
18
18
  key.should == t
19
19
  end
@@ -31,4 +31,4 @@ describe PageObject::Elements::Button do
31
31
  end
32
32
  end
33
33
 
34
- end
34
+ end
@@ -34,6 +34,16 @@ describe PageObject::Elements::Table do
34
34
  watir_table[1].should be_instance_of PageObject::Elements::TableRow
35
35
  end
36
36
 
37
+ it "should return the first row" do
38
+ table_element.stub(:[]).with(0).and_return(table_element)
39
+ watir_table.first_row.should be_instance_of PageObject::Elements::TableRow
40
+ end
41
+
42
+ it "shoudl return the last row" do
43
+ table_element.stub(:[]).with(-1).and_return(table_element)
44
+ watir_table.last_row.should be_instance_of PageObject::Elements::TableRow
45
+ end
46
+
37
47
  it "should return the number of rows" do
38
48
  table_element.stub(:wd).and_return(table_element)
39
49
  table_element.should_receive(:find_elements).with(:xpath, ".//child::tr").and_return(table_element)
@@ -57,6 +67,16 @@ describe PageObject::Elements::Table do
57
67
  selenium_table[1].should be_instance_of PageObject::Elements::TableRow
58
68
  end
59
69
 
70
+ it "should return the first row" do
71
+ table_element.stub(:[]).with(0).and_return(table_element)
72
+ selenium_table.first_row.should be_instance_of PageObject::Elements::TableRow
73
+ end
74
+
75
+ it "shoudl return the last row" do
76
+ table_element.stub(:[]).with(-1).and_return(table_element)
77
+ selenium_table.last_row.should be_instance_of PageObject::Elements::TableRow
78
+ end
79
+
60
80
  it "should return the number of rows" do
61
81
  table_element.should_receive(:find_elements).with(:xpath, ".//child::tr").and_return(table_element)
62
82
  table_element.should_receive(:size).and_return(2)
@@ -71,4 +91,4 @@ describe PageObject::Elements::Table do
71
91
  end
72
92
  end
73
93
  end
74
- end
94
+ end
metadata CHANGED
@@ -1,82 +1,78 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: page-object
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.5.2
4
5
  prerelease:
5
- version: 0.5.1
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Jeff Morgan
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-11-18 00:00:00 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2011-11-30 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: watir-webdriver
17
- prerelease: false
18
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &70095900630940 !ruby/object:Gem::Requirement
19
17
  none: false
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 0.3.9
24
22
  type: :runtime
25
- version_requirements: *id001
26
- - !ruby/object:Gem::Dependency
27
- name: selenium-webdriver
28
23
  prerelease: false
29
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *70095900630940
25
+ - !ruby/object:Gem::Dependency
26
+ name: selenium-webdriver
27
+ requirement: &70095900629300 !ruby/object:Gem::Requirement
30
28
  none: false
31
- requirements:
32
- - - ">="
33
- - !ruby/object:Gem::Version
34
- version: 2.12.2
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: 2.14.0
35
33
  type: :runtime
36
- version_requirements: *id002
37
- - !ruby/object:Gem::Dependency
38
- name: rspec
39
34
  prerelease: false
40
- requirement: &id003 !ruby/object:Gem::Requirement
35
+ version_requirements: *70095900629300
36
+ - !ruby/object:Gem::Dependency
37
+ name: rspec
38
+ requirement: &70095900627260 !ruby/object:Gem::Requirement
41
39
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
45
43
  version: 2.6.0
46
44
  type: :development
47
- version_requirements: *id003
48
- - !ruby/object:Gem::Dependency
49
- name: cucumber
50
45
  prerelease: false
51
- requirement: &id004 !ruby/object:Gem::Requirement
46
+ version_requirements: *70095900627260
47
+ - !ruby/object:Gem::Dependency
48
+ name: cucumber
49
+ requirement: &70095900626440 !ruby/object:Gem::Requirement
52
50
  none: false
53
- requirements:
54
- - - ">="
55
- - !ruby/object:Gem::Version
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
56
54
  version: 1.1.0
57
55
  type: :development
58
- version_requirements: *id004
59
- - !ruby/object:Gem::Dependency
60
- name: yard
61
56
  prerelease: false
62
- requirement: &id005 !ruby/object:Gem::Requirement
57
+ version_requirements: *70095900626440
58
+ - !ruby/object:Gem::Dependency
59
+ name: yard
60
+ requirement: &70095900625280 !ruby/object:Gem::Requirement
63
61
  none: false
64
- requirements:
65
- - - ">="
66
- - !ruby/object:Gem::Version
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
67
65
  version: 0.7.2
68
66
  type: :development
69
- version_requirements: *id005
67
+ prerelease: false
68
+ version_requirements: *70095900625280
70
69
  description: Page Object DSL that works with both Watir and Selenium
71
- email:
70
+ email:
72
71
  - jeff.morgan@leandog.com
73
72
  executables: []
74
-
75
73
  extensions: []
76
-
77
74
  extra_rdoc_files: []
78
-
79
- files:
75
+ files:
80
76
  - .gitignore
81
77
  - .rspec
82
78
  - .rvmrc
@@ -102,6 +98,7 @@ files:
102
98
  - features/html/frames.html
103
99
  - features/html/iframes.html
104
100
  - features/html/images/circle.png
101
+ - features/html/images/submit.gif
105
102
  - features/html/modal.html
106
103
  - features/html/modal_1.html
107
104
  - features/html/modal_2.html
@@ -254,32 +251,29 @@ files:
254
251
  - spec/spec_helper.rb
255
252
  homepage: http://github.com/cheezy/page-object
256
253
  licenses: []
257
-
258
254
  post_install_message:
259
255
  rdoc_options: []
260
-
261
- require_paths:
256
+ require_paths:
262
257
  - lib
263
- required_ruby_version: !ruby/object:Gem::Requirement
258
+ required_ruby_version: !ruby/object:Gem::Requirement
264
259
  none: false
265
- requirements:
266
- - - ">="
267
- - !ruby/object:Gem::Version
268
- version: "0"
269
- required_rubygems_version: !ruby/object:Gem::Requirement
260
+ requirements:
261
+ - - ! '>='
262
+ - !ruby/object:Gem::Version
263
+ version: '0'
264
+ required_rubygems_version: !ruby/object:Gem::Requirement
270
265
  none: false
271
- requirements:
272
- - - ">="
273
- - !ruby/object:Gem::Version
274
- version: "0"
266
+ requirements:
267
+ - - ! '>='
268
+ - !ruby/object:Gem::Version
269
+ version: '0'
275
270
  requirements: []
276
-
277
271
  rubyforge_project: page-object
278
272
  rubygems_version: 1.8.10
279
273
  signing_key:
280
274
  specification_version: 3
281
275
  summary: Page Object DSL for browser testing
282
- test_files:
276
+ test_files:
283
277
  - features/async.feature
284
278
  - features/button.feature
285
279
  - features/check_box.feature
@@ -295,6 +289,7 @@ test_files:
295
289
  - features/html/frames.html
296
290
  - features/html/iframes.html
297
291
  - features/html/images/circle.png
292
+ - features/html/images/submit.gif
298
293
  - features/html/modal.html
299
294
  - features/html/modal_1.html
300
295
  - features/html/modal_2.html