Permalink
Browse files

Removed local page references from Cucumber steps

  • Loading branch information...
alisterscott committed Jun 7, 2011
1 parent 7130c58 commit 47f6d611057faa1106026ea2d22ce89f7483026c
Showing with 42 additions and 18 deletions.
  1. +21 −8 features/step_definitions/search_steps.rb
  2. +21 −10 features/support/env.rb
@@ -1,28 +1,41 @@
Given /^I am on the (.+)$/ do |page_name|
@home_page = Object.const_get(page_name.gsub(" ","")).new(@browser, true)
Given /^I am on the (.+) Home Page$/ do |site|
site site
visit :Home
end
When /^I search for a? ?"([^"]*)"$/ do |term|
@results_page = @home_page.search_for term
on :Home do |page|
page.search_for term
end
end
When /^I search for a?n? ?([^"].+[^"])$/ do |term|
term = Common.get_search_term_data term
@results_page = @home_page.search_for term
on :Home do |page|
page.search_for term
end
end
Then /^I should see at least ([\d,]+) results$/ do |exp_num_results|
@results_page.number_search_results.should >= exp_num_results.gsub(",","").to_i
on :Results do |page|
page.number_search_results.should >= exp_num_results.gsub(",","").to_i
end
end
Then /^I should see at most ([\d,]+) results$/ do |exp_num_results|
@results_page.number_search_results.should <= exp_num_results.gsub(",","").to_i
on :Results do |page|
page.number_search_results.should <= exp_num_results.gsub(",","").to_i
end
end
When /^I convert (.+)$/ do |conversion_statement|
@results_page = @home_page.search_for "convert #{conversion_statement}"
on :Home do |page|
page.search_for "convert #{conversion_statement}"
end
end
Then /^I should see the conversion result "([^"]*)"$/ do |exp_conversion_result|
@results_page.conversion_result.should == exp_conversion_result
on :Results do |page|
page.conversion_result.should == exp_conversion_result
end
end
View
@@ -5,18 +5,29 @@
require File.dirname(__FILE__)+'/pages/base_page_class'
require File.dirname(__FILE__)+'/pages/search_page_class'
if ENV["HEADLESS"] then
include Selenium
capabilities = WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
browser = Watir::Browser.new(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => capabilities)
else
browser = Watir::Browser.new :firefox
end
Before do
@browser = browser
module Browser
BROWSER = Watir::Browser.new ENV['WEB_DRIVER'] || :firefox
def visit page_class, &block
on page_class, true, &block
end
def on page, visit=false, &block
page_class = Object.const_get "#{@site}#{page}Page"
page = page_class.new BROWSER, visit
block.call page if block
page
end
def site name
@site = name
end
end
World Browser
at_exit do
browser.close
Browser::BROWSER.close
end

0 comments on commit 47f6d61

Please sign in to comment.