page-object 0.6.8 → 0.6.9

Sign up to get free protection for your applications and to get access to all the features.
data/ChangeLog CHANGED
@@ -1,3 +1,13 @@
1
+ === Version 0.6.9 / 2012-6-12
2
+ * Enhancements
3
+ * Added select_value method to SelectList
4
+ * Updated link to be able to identify by title
5
+ * Updated div to be able to identify by title
6
+ * Updated text_field to be able to identify by text and label
7
+ * Updated to use selenium-webdriver 2.22.2
8
+ * Fixes
9
+ * Fixed populate_page_with to work with text areas (Thanks ramyav85)
10
+
1
11
  === Version 0.6.8 / 2012-6-3
2
12
  * Enhancements
3
13
  * Updated [] method on Table to return nil when bad row header is provided
@@ -27,6 +27,7 @@ Feature: Div
27
27
  | index |
28
28
  | name |
29
29
  | text |
30
+ | title |
30
31
 
31
32
  Scenario Outline: Locating divs using multiple parameters
32
33
  When I search for the div by "<param1>" and "<param2>"
@@ -5,6 +5,7 @@
5
5
  <body>
6
6
  <p id='p_id' name='p_name' class='p_class'>Static Elements Page</p>
7
7
 
8
+ <label for="text_field_id">Text Field</label>
8
9
  <input id="text_field_id" name="text_field_name" class="text_field_class"
9
10
  title="text_field_title" size="40" type="text"/>
10
11
 
@@ -24,14 +25,14 @@
24
25
  <option value="option3" selected="true">Test 3</option>
25
26
  </select>
26
27
 
27
- <a href="success.html" id="link_id" name="link_name" class="link_class">Google Search</a>
28
+ <a href="success.html" id="link_id" name="link_name" class="link_class" title="link_title">Google Search</a>
28
29
 
29
30
  <input id="cb_id" name="cb_name" class="cb_class" type="checkbox" value="1"/>
30
31
 
31
32
  <input type="radio" id="milk_id" name="milk_name" class="milk_class" value="Milk"> Milk <br/>
32
33
  <input type="radio" id="butter_id" name="butter_name" class="butter_class" value="Butter">Butter
33
34
 
34
- <div id="div_id" name="div_name" class="div_class">
35
+ <div id="div_id" name="div_name" class="div_class" title="div_title">
35
36
  page-object rocks!
36
37
  </div>
37
38
 
@@ -42,3 +42,4 @@ Feature: Handling labels with page object
42
42
  When I get the text from a label while the script is executing
43
43
  Then I should see that the label exists
44
44
  And the text should be "page-object is the best!"
45
+
@@ -25,6 +25,7 @@ Feature: Links
25
25
  | index |
26
26
  | href |
27
27
  | css |
28
+ | title |
28
29
 
29
30
  Scenario: Support for multiple parameters
30
31
  When I select a link labeled "Hello" and index "0"
@@ -60,3 +60,7 @@ Feature: Select List
60
60
  Scenario: Clearing multiple select list
61
61
  When I clear multiple select list
62
62
  Then multiple select list should have no selected options
63
+
64
+ Scenario: Selecting an option by its value
65
+ When I select an option using the value "option2"
66
+ Then the selected option should be "Test 2"
@@ -55,3 +55,7 @@ end
55
55
  Then /^multiple select list should have no selected options$/ do
56
56
  @page.sel_list_multiple_element.selected_options.should be_empty
57
57
  end
58
+
59
+ When /^I select an option using the value "([^\"]*)"$/ do |value|
60
+ @page.sel_list_id_element.select_value(value)
61
+ end
@@ -17,6 +17,7 @@ class Page
17
17
  text_field(:text_field_index, :index => 0)
18
18
  text_field(:text_field_text, :text => "")
19
19
  text_field(:text_field_value, :value => "")
20
+ text_field(:text_field_label, :label => "Text Field")
20
21
  text_field(:text_field_title, :title => 'text_field_title')
21
22
  text_field(:text_field_class_index, :class => "text_field_class", :index => 0)
22
23
  text_field(:text_field_name_index, :name => "text_field_name", :index => 0)
@@ -55,6 +56,7 @@ class Page
55
56
  link(:google_search_text, :text => "Google Search")
56
57
  link(:google_search_index, :index => 0)
57
58
  link(:google_search_css, :css => "a.link_class")
59
+ link(:google_search_title, :title => "link_title")
58
60
 
59
61
  select_list(:sel_list_id, :id => "sel_list_id")
60
62
  select_list(:sel_list_class, :class => "sel_list_class")
@@ -93,6 +95,7 @@ class Page
93
95
  div(:div_text, :text => 'page-object rocks!')
94
96
  div(:div_index, :index => 0)
95
97
  div(:div_xpath, :xpath => '//div')
98
+ div(:div_title, :title => 'div_title')
96
99
  div(:div_class_index, :class => "div_class", :index => 0)
97
100
  div(:div_name_index, :name => "div_name", :index => 0)
98
101
 
@@ -265,8 +268,8 @@ class Page
265
268
  label(:label_name, :name => 'label_name')
266
269
  label(:label_class, :class => 'label_class')
267
270
  label(:label_text, :text => 'page-object is the best!')
268
- label(:label_index, :index => 0)
269
- label(:label_xpath, :xpath => '//label')
271
+ label(:label_index, :index => 1)
272
+ label(:label_xpath, :xpath => '//label[2]')
270
273
  label(:label_class_index, :class => "label_class", :index => 0)
271
274
  label(:label_name_index, :name => "label_name", :index => 0)
272
275
 
@@ -22,6 +22,8 @@ Feature: Text Fields
22
22
  | xpath |
23
23
  | index |
24
24
  | title |
25
+ | text |
26
+ | label |
25
27
 
26
28
  Scenario Outline: Locating a text field using multiple parameters
27
29
  When I search for the text field by "<param1>" and "<param2>"
@@ -99,8 +99,9 @@ module PageObject
99
99
  # * :class => Watir and Selenium
100
100
  # * :id => Watir and Selenium
101
101
  # * :index => Watir and Selenium
102
+ # * :label => Watir and Selenium
102
103
  # * :name => Watir and Selenium
103
- # * :text => Watir only
104
+ # * :text => Watir and Selenium
104
105
  # * :title => Watir and Selenium
105
106
  # * :value => Watir only
106
107
  # * :xpath => Watir and Selenium
@@ -266,6 +267,7 @@ module PageObject
266
267
  # * :link_text => Watir and Selenium
267
268
  # * :name => Watir and Selenium
268
269
  # * :text => Watir and Selenium
270
+ # * :title => Watir and Selenium
269
271
  # * :xpath => Watir and Selenium
270
272
  # @param optional block to be invoked when element method is called
271
273
  #
@@ -433,6 +435,7 @@ module PageObject
433
435
  # * :index => Watir and Selenium
434
436
  # * :name => Watir and Selenium
435
437
  # * :text => Watir and Selenium
438
+ # * :title => Watir and Selenium
436
439
  # * :xpath => Watir and Selenium
437
440
  # @param optional block to be invoked when element method is called
438
441
  #
@@ -5,11 +5,11 @@ module PageObject
5
5
  protected
6
6
 
7
7
  def self.watir_finders
8
- [:class, :id, :name, :text, :index, :xpath]
8
+ super + [:text, :title]
9
9
  end
10
10
 
11
11
  def self.selenium_finders
12
- [:class, :id, :name, :text, :xpath, :index]
12
+ super + [:text, :title]
13
13
  end
14
14
 
15
15
  end
@@ -11,7 +11,7 @@ module PageObject
11
11
  protected
12
12
 
13
13
  def self.watir_finders
14
- super + [:href, :text, :css]
14
+ super + [:href, :text, :css, :title]
15
15
  end
16
16
 
17
17
  def self.watir_mapping
@@ -19,7 +19,7 @@ module PageObject
19
19
  end
20
20
 
21
21
  def self.selenium_finders
22
- super + [:link, :link_text, :css]
22
+ super + [:link, :link_text, :css, :title]
23
23
  end
24
24
 
25
25
  def self.selenium_mapping
@@ -15,11 +15,11 @@ module PageObject
15
15
  protected
16
16
 
17
17
  def self.watir_finders
18
- super + [:title]
18
+ super + [:title, :value, :text, :label]
19
19
  end
20
20
 
21
21
  def self.selenium_finders
22
- super + [:title]
22
+ super + [:title, :value, :text, :label]
23
23
  end
24
24
 
25
25
  def include_platform_for platform
@@ -0,0 +1,19 @@
1
+ module PageObject
2
+ module Javascript
3
+
4
+ module YUI
5
+ #
6
+ # return the number of pending ajax requests
7
+ #
8
+ def self.pending_requests
9
+ "var inProgress=0
10
+ for(var i=0; i < YAHOO.util.Connect._transaction_id; i++) {
11
+ if(YAHOO.util.Connect.isCallInProgress(i))
12
+ inProgress++;
13
+ }
14
+ return inProgress;"
15
+ end
16
+ end
17
+
18
+ end
19
+ end
@@ -1,5 +1,6 @@
1
1
  require 'page-object/javascript/jquery'
2
2
  require 'page-object/javascript/prototype'
3
+ require 'page-object/javascript/yui'
3
4
 
4
5
 
5
6
  module PageObject
@@ -61,6 +62,7 @@ module PageObject
61
62
  @builder = {
62
63
  :jquery => ::PageObject::Javascript::JQuery,
63
64
  :prototype => ::PageObject::Javascript::Prototype,
65
+ :yui => ::PageObject::Javascript::YUI,
64
66
  }
65
67
  end
66
68
 
@@ -66,6 +66,7 @@ module PageObject
66
66
  end
67
67
 
68
68
  def is_enabled?(key)
69
+ return true if (self.send "#{key}_element").tag_name == "textarea"
69
70
  self.send("#{key}_element").enabled?
70
71
  end
71
72
  end
@@ -949,11 +949,15 @@ module PageObject
949
949
  return false if identifier[:src] and tag == 'input' and
950
950
  ['submit', 'image', 'button', 'reset'].include? additional[:type]
951
951
  return false if identifier[:src] and tag == 'img'
952
+ return false if identifier[:label]
952
953
  return false if identifier[:text] and tag == 'input' and additional[:type] == 'hidden'
954
+ return false if identifier[:text] and tag == 'input' and additional[:type] == 'text'
953
955
  return false if identifier[:text] and ['div', 'span', 'td', 'label'].include? tag
954
956
  return false if identifier[:title] and tag == 'input' and additional[:type] == 'text'
955
957
  return false if identifier[:title] and tag == 'input' and additional[:type] == 'file'
958
+ return false if identifier[:title] and tag == 'a'
956
959
  return false if identifier[:title] and tag == 'span'
960
+ return false if identifier[:title] and tag == 'div'
957
961
  return false if identifier[:value] and tag == 'input' and
958
962
  ['radio', 'submit', 'image', 'button', 'reset', 'checkbox', 'hidden'].include? additional[:type]
959
963
  true
@@ -22,6 +22,17 @@ module PageObject
22
22
  end.click
23
23
  end
24
24
 
25
+ #
26
+ # Select the option(s) whose value attribute matches the given
27
+ # string
28
+ #
29
+ def select_value(value)
30
+ options = find_options.find_all do |option|
31
+ option.attribute('value') == value
32
+ end
33
+ options.each {|opt| opt.click}
34
+ end
35
+
25
36
  #
26
37
  # Return an array of Options contained in the select lit.
27
38
  #
@@ -20,6 +20,14 @@ module PageObject
20
20
  element.select(value)
21
21
  end
22
22
 
23
+ #
24
+ # Select the option(s) whose value attribute matches the given
25
+ # string
26
+ #
27
+ def select_value(value)
28
+ element.select_value(value)
29
+ end
30
+
23
31
  #
24
32
  # Return an array of Options contained in the select lit.
25
33
  #
@@ -1,4 +1,4 @@
1
1
  module PageObject
2
2
  # @private
3
- VERSION = "0.6.8"
3
+ VERSION = "0.6.9"
4
4
  end
@@ -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.6.1'
23
- s.add_dependency 'selenium-webdriver', '>= 2.22.1'
23
+ s.add_dependency 'selenium-webdriver', '>= 2.22.2'
24
24
 
25
25
  s.add_development_dependency 'rspec', '>= 2.6.0'
26
26
  s.add_development_dependency 'cucumber', '< 1.2.0'
@@ -6,14 +6,14 @@ describe PageObject::Elements::Div do
6
6
 
7
7
  describe "when mapping how to find an element" do
8
8
  it "should map watir types to same" do
9
- [:class, :id, :text, :index, :xpath].each do |t|
9
+ [:class, :id, :text, :index, :xpath, :name, :title].each do |t|
10
10
  identifier = div.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, :text, :index, :name, :xpath].each do |t|
16
+ [:class, :id, :text, :index, :name, :xpath, :title].each do |t|
17
17
  key, value = div.selenium_identifier_for t => 'value'
18
18
  key.should == t
19
19
  end
@@ -6,7 +6,7 @@ describe PageObject::Elements::Link do
6
6
 
7
7
  describe "when mapping how to find an element" do
8
8
  it "should map watir types to same" do
9
- [:class, :href, :id, :index, :name, :text, :xpath, :css].each do |t|
9
+ [:class, :href, :id, :index, :name, :text, :xpath, :css, :title].each do |t|
10
10
  identifier = link.watir_identifier_for t => 'value'
11
11
  identifier.keys.first.should == t
12
12
  end
@@ -20,7 +20,7 @@ describe PageObject::Elements::Link do
20
20
  end
21
21
 
22
22
  it "should map selenium types to same" do
23
- [:class, :id, :link, :link_text, :name, :xpath, :index, :css].each do |t|
23
+ [:class, :id, :link, :link_text, :name, :xpath, :index, :css, :title].each do |t|
24
24
  key, value = link.selenium_identifier_for t => 'value'
25
25
  key.should == t
26
26
  end
@@ -7,14 +7,14 @@ describe PageObject::Elements::TextField do
7
7
  let(:textfield) { PageObject::Elements::TextField }
8
8
 
9
9
  it "should map watir types to same" do
10
- [:class, :id, :index, :name, :title, :xpath].each do |t|
10
+ [:class, :id, :index, :name, :title, :xpath, :text, :label].each do |t|
11
11
  identifier = textfield.watir_identifier_for t => 'value'
12
12
  identifier.keys.first.should == t
13
13
  end
14
14
  end
15
15
 
16
16
  it "should map selenium types to same" do
17
- [:class, :id, :name, :title, :xpath, :index].each do |t|
17
+ [:class, :id, :name, :title, :xpath, :index, :text, :label].each do |t|
18
18
  key, value = textfield.selenium_identifier_for t => 'value'
19
19
  key.should == t
20
20
  end
@@ -28,14 +28,16 @@ describe PageObject::PagePopulator do
28
28
 
29
29
  it "should not populate a text field when it is disabled" do
30
30
  page_object.should_not_receive(:tf=)
31
- page_object.should_receive(:tf_element).and_return(browser)
31
+ page_object.should_receive(:tf_element).twice.and_return(browser)
32
32
  browser.should_receive(:enabled?).and_return(false)
33
+ browser.should_receive(:tag_name).and_return('input')
33
34
  page_object.populate_page_with('tf' => true)
34
35
  end
35
36
 
36
37
  it "should set a value in a text area" do
37
38
  page_object.should_receive(:ta=).with('value')
38
- page_object.stub(:is_enabled?).and_return(true)
39
+ page_object.should_receive(:ta_element).and_return(browser)
40
+ browser.should_receive(:tag_name).and_return('textarea')
39
41
  page_object.populate_page_with('ta' => 'value')
40
42
  end
41
43
 
@@ -77,15 +79,17 @@ describe PageObject::PagePopulator do
77
79
 
78
80
  it "should not populate a checkbox if it is disabled" do
79
81
  page_object.should_not_receive(:check_cb)
80
- page_object.should_receive(:cb_element).and_return(browser)
82
+ page_object.should_receive(:cb_element).twice.and_return(browser)
81
83
  browser.should_receive(:enabled?).and_return(false)
84
+ browser.should_receive(:tag_name).and_return('input')
82
85
  page_object.populate_page_with('cb' => true)
83
86
  end
84
87
 
85
88
  it "should not populate a radio button when it is disabled" do
86
89
  page_object.should_not_receive(:select_rb)
87
- page_object.should_receive(:rb_element).and_return(browser)
90
+ page_object.should_receive(:rb_element).twice.and_return(browser)
88
91
  browser.should_receive(:enabled?).and_return(false)
92
+ browser.should_receive(:tag_name).and_return('input')
89
93
  page_object.populate_page_with('rb' => true)
90
94
  end
91
95
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: page-object
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.8
4
+ version: 0.6.9
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-03 00:00:00.000000000 Z
12
+ date: 2012-06-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: watir-webdriver
16
- requirement: &70276232212840 !ruby/object:Gem::Requirement
16
+ requirement: &70157117515820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,21 +21,21 @@ dependencies:
21
21
  version: 0.6.1
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70276232212840
24
+ version_requirements: *70157117515820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: selenium-webdriver
27
- requirement: &70276232228720 !ruby/object:Gem::Requirement
27
+ requirement: &70157117515320 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 2.22.1
32
+ version: 2.22.2
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70276232228720
35
+ version_requirements: *70157117515320
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70276232228260 !ruby/object:Gem::Requirement
38
+ requirement: &70157117514860 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 2.6.0
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70276232228260
46
+ version_requirements: *70157117514860
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: cucumber
49
- requirement: &70276232227800 !ruby/object:Gem::Requirement
49
+ requirement: &70157117514400 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - <
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.2.0
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70276232227800
57
+ version_requirements: *70157117514400
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &70276232227340 !ruby/object:Gem::Requirement
60
+ requirement: &70157117513940 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.7.2
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70276232227340
68
+ version_requirements: *70157117513940
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rack
71
- requirement: &70276232226880 !ruby/object:Gem::Requirement
71
+ requirement: &70157117513480 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '1.0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70276232226880
79
+ version_requirements: *70157117513480
80
80
  description: Page Object DSL that works with both Watir and Selenium
81
81
  email:
82
82
  - jeff.morgan@leandog.com
@@ -218,6 +218,7 @@ files:
218
218
  - lib/page-object/elements/unordered_list.rb
219
219
  - lib/page-object/javascript/jquery.rb
220
220
  - lib/page-object/javascript/prototype.rb
221
+ - lib/page-object/javascript/yui.rb
221
222
  - lib/page-object/javascript_framework_facade.rb
222
223
  - lib/page-object/loads_platform.rb
223
224
  - lib/page-object/nested_elements.rb