Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

added default parameter for table_elements

  • Loading branch information...
commit 5762a499c1370f40500b5ca8840d378896f1eda0 1 parent 357696f
@cheezy authored
View
1  features/multi_elements.feature
@@ -89,6 +89,7 @@ Feature: Multi Elements
And the first row first column for table 1 should have "Data 1"
And the first row first column for table 2 should have "Data 4"
And the first row first column for table 3 should have "Data 7"
+ And I should be able to find all 3 tables using no identifier
Scenario: Selecting cells
When I select the cells with class "td"
View
5 features/step_definitions/multi_elements_steps.rb
@@ -335,3 +335,8 @@ class MultiElementsPage
Then /^I should be able to find all (\d+) spans using no identifier$/ do |num_spans|
@page.span_elements.size.should == num_spans.to_i
end
+
+Then /^I should be able to find all (\d+) tables using no identifier$/ do |num_tables|
+ @page.table_elements.size.should == num_tables.to_i
+end
+
View
8 lib/page-object/element_locators.rb
@@ -371,7 +371,8 @@ def span_elements(identifier={})
# Finds a table
#
# @param [Hash] identifier how we find a table. You can use a multiple paramaters
- # by combining of any of the following except xpath. The valid keys are:
+ # by combining of any of the following except xpath. It defaults to {:index => 0}
+ # which will return the first table. The valid keys are:
# * :class => Watir and Selenium
# * :id => Watir and Selenium
# * :index => Watir and Selenium
@@ -386,14 +387,15 @@ def table_element(identifier={:index => 0})
# Finds all tables that match the provided identifier
#
# @param [Hash] identifier how we find a table. You can use a multiple paramaters
- # by combining of any of the following except xpath. The valid keys are:
+ # by combining of any of the following except xpath. It defaults to an empty Hash
+ # which will return all tables. The valid keys are:
# * :class => Watir and Selenium
# * :id => Watir and Selenium
# * :index => Watir and Selenium
# * :name => Watir and Selenium
# * :xpath => Watir and Selenium
#
- def table_elements(identifier)
+ def table_elements(identifier={})
platform.tables_for(identifier.clone)
end
View
5 spec/page-object/element_locators_spec.rb
@@ -249,6 +249,11 @@ class ElementLocatorsTestPageObject
elements = watir_page_object.table_elements(:id => 'blah')
elements[0].should be_instance_of PageObject::Elements::Table
end
+
+ it "should find all table elements using no identifier" do
+ watir_browser.should_receive(:tables).with({}).and_return([watir_browser])
+ watir_page_object.table_elements
+ end
it "should find a table cell" do
watir_browser.should_receive(:td).with(:id => 'blah').and_return(watir_browser)
Please sign in to comment.
Something went wrong with that request. Please try again.