shared behaviors

5 views
Skip to first unread message

Andy

unread,
Sep 10, 2009, 11:06:06 AM9/10/09
to Easyb Users
FYI, the newest version of easyb also supports the notion of shared
behaviors. See http://code.google.com/p/easyb/wiki/SharedBehaviors for
more information. At this point, the sharing is intra-file based --
ideally, we can break this up into other files, etc.

Feedback, comments, rants are welcome as always!

savaged

unread,
Oct 15, 2009, 9:36:12 AM10/15/09
to Easyb Users
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>

Andy

unread,
Oct 22, 2009, 4:58:22 PM10/22/09
to Easyb Users
You could create a plug-in that does this for you -- it is a version
of a shared behavior and thus, you could have your "setup" before any
story -- see http://code.google.com/p/easyb/wiki/PluginAPI
Reply all
Reply to author
Forward
0 new messages