Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

populate_page_with now supports radio groups

  • Loading branch information...
commit d5fcffb2ce4bcda60e834cc70e52148a1f8d29c5 1 parent b9bd99c
@cheezy authored
View
4 ChangeLog
@@ -1,3 +1,7 @@
+=== Version 0.9.8
+* Enhancements
+ * populate_page_with not supports radio groups
+
=== Version 0.9.7 / 2014-2-26
* Enhancements
* Table now supports exists?
View
8 features/radio_button_group.feature
@@ -16,12 +16,12 @@ Feature: Radio Button Groups
Scenario: Selecting grouped radio buttons by value
When I select the "ched" radio button in the group
Then the "ched" radio button should be selected in the group
- Then the "emmen" radio button should not be selected
- Then the "muen" radio button should not be selected
+ And the "emmen" radio button should not be selected
+ And the "muen" radio button should not be selected
When I select the "muen" radio button in the group
Then the "ched" radio button should not be selected
- Then the "emmen" radio button should not be selected
- Then the "muen" radio button should be selected in the group
+ And the "emmen" radio button should not be selected
+ And the "muen" radio button should be selected in the group
Scenario: Getting an array of elements for each radio button in the group
When I ask for the elements of a radio button group
View
10 lib/page-object/page_populator.rb
@@ -32,6 +32,7 @@ module PagePopulator
def populate_page_with(data)
data.each do |key, value|
populate_checkbox(key, value) if is_checkbox?(key) and is_enabled?(key)
+ populate_radiobuttongroup(key, value) if is_radiobuttongroup?(key)
populate_radiobutton(key, value) if is_radiobutton?(key) and is_enabled?(key)
populate_text(key, value) if is_text?(key) and is_enabled?(key)
end
@@ -53,6 +54,10 @@ def populate_radiobutton(key, value)
return self.send "clear_#{key}"
end
+ def populate_radiobuttongroup(key, value)
+ return self.send("select_#{key}", value)
+ end
+
def is_text?(key)
respond_to?("#{key}=".to_sym)
end
@@ -65,7 +70,12 @@ def is_radiobutton?(key)
respond_to?("select_#{key}".to_sym)
end
+ def is_radiobuttongroup?(key)
+ respond_to?("select_#{key}".to_sym) and respond_to?("#{key}_values")
+ end
+
def is_enabled?(key)
+ return false if is_radiobuttongroup?(key)
return true if (self.send "#{key}_element").tag_name == "textarea"
element = self.send("#{key}_element")
element.enabled? and element.visible?
View
6 spec/page-object/page_populator_spec.rb
@@ -9,6 +9,7 @@ class PageObjectTestPageObject
file_field(:ff, :id => 'id')
checkbox(:cb, :id => 'id')
radio_button(:rb, :id => 'id')
+ radio_button_group(:rbg, :id => 'id')
end
describe PageObject::PagePopulator do
@@ -86,6 +87,11 @@ class PageObjectTestPageObject
page_object.populate_page_with('rb' => false)
end
+ it "should select the correct element from a radio button group" do
+ page_object.should_receive(:select_rbg).with('blah')
+ page_object.populate_page_with('rbg' => 'blah')
+ end
+
it "should not populate a checkbox if it is disabled" do
page_object.should_not_receive(:check_cb)
page_object.should_receive(:cb_element).twice.and_return(browser)
Please sign in to comment.
Something went wrong with that request. Please try again.