Is this feature set the way to go for the following situation, I face?
I have a set of user-stories which use Selenium; I want to use
"before" and "after" to start and close my DefaultSelenium session. If
i split the stories out to individual files, I get better results from
easyb; however, i find myself then having the "before" and "after"
repeated in each file. How do i best manage this re-use issue? Could
"shared behaviours" be the answer, or is there another better route?
Here's an example of the sort of thing i want to do (of course it's
just a silly example, not the real thing):
<code>
import com.thoughtworks.selenium.DefaultSelenium
before 'start selenium', {
given 'selenium is up and running', {
selenium = new DefaultSelenium(
'localhost',
4444,
'*iexplore',
'
http://www.google.co.uk')
selenium.start()
}
}
description 'these are a set of stories about googling for
savaged.info'
narrative 'user-story 1: searching for
savaged.info on google', {
as a 'person who uses google'
i want 'to search for a set of internet links for a phrase'
so that 'I can find information online'
}
scenario 'the search phrase has been entered', {
given 'the google search page is ready', {
selenium.open '/'
}
when 'filling out the search with a phrase', {
selenium.type 'q', '
savaged.info'
}
and 'the submit button has been clicked', {
selenium.click 'btnG'
}
then 'the results should have a list of links for that phrase', {
selenium.waitForPageToLoad '5000'
selenium.isTextPresent 'Results * for
savaged.info'
}
}
narrative 'user-story 2: clicking the result from googling for
savaged.info', {
as a 'person who uses google'
i want 'to click one of the internet links returned by my google
search'
so that "I can get to the page I'm intereseted in"
}
scenario 'the search phrase has been entered', {
given 'the google search results are ready', {
selenium.isTextPresent 'Results * for
savaged.info'
}
when 'clicking the desired link', {
selenium.click "//div[@id='res']/div[1]/ol/li[1]/h3/a/em[1]"
}
then 'the expected page should be presented', {
selenium.waitForPageToLoad '5000'
selenium.isTextPresent '
savaged.info'
}
}
after 'stop selenium', {
then 'selenium should be shutdown', {
selenium.stop()
}
}
</code>