Try this:
1. Save the following cucumber file under C:\somenewplace\features
\hillary.feature

Feature: Cucumber Question
  Scenario: Google Search for delicious
    Given I am on Google Search Home Page
    When I search for "delicious"
    Then I should find "delicious"

  Scenario: Google Search for Facebook
    Given I am on Google Search Home Page
    When I search for "Facebook"
    Then I should find "Facebook"

2. Run cucumber on the feature file above to generate a skeletal file
that you can use in your steps file.
(ie. from C:\somenewplace,  cucumber features\hillary.feature)
You'll get some generated code that you can use later.

Save my solution below under  C:\somenewplace\features\step_definitions
\hillary_steps.rb
If you compare it to what you generated from step 1, you can see that
I don't hard code the search terms so that I can reuse the code to
match other words.

require 'watir-webdriver'

Given /^I am on Google Search Home Page$/ do
  @browser = Watir::Browser.new :firefox
  @browser.goto "http://google.com";
end

When /^I search for "([^*"]*)"$/ do |arg1|
  @browser.text_field(:name, "q").set(arg1)
  @browser.button(:name,"btnG").click
end

Then /^I should find "([^"]*)"$/ do |arg1|
  @browser.text.include?(arg1)
  @browser.quit
end

3. Now run cucumber again from C:\somenewplace
E:\CucumberExamples>cucumber features\hillary.feature
Feature: Cucumber Question

  Scenario: Google Search for delicious   # features\hillary.feature:2
    Given I am on Google Search Home Page # features/step_definitions/
hillary_st
eps.rb:3
    When I search for "delicious"         # features/step_definitions/
hillary_st
eps.rb:8
    Then I should find "delicious"        # features/step_definitions/
hillary_st
eps.rb:13

  Scenario: Google Search for Facebook    # features\hillary.feature:7
    Given I am on Google Search Home Page # features/step_definitions/
hillary_st
eps.rb:3
    When I search for "Facebook"          # features/step_definitions/
hillary_st
eps.rb:8
    Then I should find "Facebook"         # features/step_definitions/
hillary_st
eps.rb:13

2 scenarios (2 passed)
6 steps (6 passed)
1m14.453s

On Sep 29, 5:39 pm, hillary <[email protected]> wrote:
> i fixed this error by moving the @browser = to the given I'm on the Google
> search home page step.
>
> Now my tests are running, but it's failing on the last step. I'm getting an
> argument error:
>
> My code  
>
> Then /^I should see "Delicious"$/ do |results|
>   @browser.text.should include "Delicious"
> end
>
> Feature: Google Search
>   In order to find out more about the delicious relaunch failure
>   I need to be able to search google
>
>   Scenario:                                      #
> features\google_search.feature:
> 5
>     Google Search for delicious relaunch failure
>     Given I am on the Google Search Home Page    #
> features/step_definitions/googl
> e_search.rb:6
>     When I search for delicious relaunch failure #
> features/step_definitions/googl
> e_search.rb:11
>     Then I should see "Delicious"                #
> features/step_definitions/googl
> e_search.rb:16
>       Your block takes 1 argument, but the Regexp matched 0 arguments.
> (Cucumber::
> ArityMismatchError)
>       features/step_definitions/google_search.rb:16:in `/^I should see
> "Delicious"
> $/'
>       features\google_search.feature:9:in `Then I should see "Delicious"'
>
> Failing Scenarios:
> cucumber features\google_search.feature:5 # Scenario:
> Google Search for delicious relaunch failure
>
> 1 scenario (1 failed)
> 3 steps (1 failed, 2 passed)
> 0m7.930s

-- 
Before posting, please read http://watir.com/support. In short: search before 
you ask, be nice.

[email protected]
http://groups.google.com/group/watir-general
[email protected]

Reply via email to