Hi,

Suppose I want to run a step only once before a feature, then how do I
write it? If I add the background section to a scenario outline which has
data tables, then with each scenario the background is implemented. Also I
tried the Before hook in env.rb but it is not suiting the test case. I have
also tried the before scenario hook, I am looking for a before feature hook
basically. Following is the scenario I want to handle:

Feature: Search
Background:
Given that I am on the home page

Scenario Outline: When I search for the following queries then I should get
the respective results

When I search for <search query>
Then the keyword <highlight keyword> should be highlighted
And <x> x should be highlighted
And <y> y should be highlighted
Examples:
|search query   | highlight keyword| x | y |
|strawberry   | strawberry | No |No |
|apple  | apple |No | No |
|mango   | mango | yes | No    |


step:definitions.rb:
Given(/^that I am on the home page$/) do

  @browser.goto("www.example.com")
end

When(/^I search for strawberry$/) do
  @browser.text_field(:id => "searchbox").wait_until_present
  @browser.text_field(:id => "searchbox").set "strawberry"
  @browser.send_keys :enter
  sleep 1
end

-----------------------------------------------

In the above case, the /Given that I am on the home page/ is executed for
each search query I want to make, which I do not want. I am basically
wanting that once I land on the home page then each of the search queries
should be executed in order of when and then (when, then, when, then, when
then)as the search bar is visible on the page, I basically do not want the
page to be reloaded on each search query I want to make.
-- 
Regards,
Anisha Narang

-- 
-- 
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]

--- 
You received this message because you are subscribed to the Google Groups 
"Watir General" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to