RE: Re: use steps from multiple step definition class for a single story
I don't have much to add since everyone already did a great job answering. I'll share our solution which is
based on the jbehave-spring-archetype available.
We have a PageObject package (all of our PageObjects representing pages on our application go here). Here
we also have a BasePage which extends org.jbehave.web.selenium.WebDriverPage (this page contains
WebDriverProvider). All of our pagesObjects extend BasePage. This way none of our pages handle the
WebDriverProvider, they all just have a call to the super ctor passing the WebDriverProvider and we get
all of those WebDriver methods findElement, etc.
In this package we also have a PageFactory class which provided the entry point where we pass the
WebDriverProvider we initialize on our spring beans.xml file.
We then have a Steps package which contains all of our steps logically combined in classes (for example
LoginSteps.java). Here we also have a BaseSteps which contain some common steps and all steps extend this
class. The constructor of this class uses PageFactory to return an instance of the relevant page object.
For example, SignIn page
Finally we initialize all of the step classes at the beginning of our run since they are defined in out spring
beans.xml file
Again, we just expanded on the jbehave-spring-archetype, so that's a great starting point
Thanks,
Enrique
-----Original Message-----
From: Alexander Lehmann [mailto:alexlehm@...]
Sent: Monday, August 06, 2012 10:25 AM
To: user@...
Subject: [jbehave-user] Re: use steps from multiple step definition class for a single story
The suggested way to implement web testing steps in to abstract from the
actual web implementation and use steps classes and another set of
classes called page classes, the examples on the reference guide
describe how to do that
http://jbehave.org/reference/web/stable/page-objects.html (WebDriver API)
The actual work is done inside the page classes that all inherit from a
class called WebDriverPage, which provides the usual WebDriver methods
like get from Selenium.
If you are constructing the objects yourself, you have to pass a
WebDriverProvider between the classes, if you are using dependency
injection (guice, spring), this will happen automatically. The whole
thing has to be run in a single thread executor unless you use a per
story web driver.
You can use steps classes (plain classes not inheriting from anything)
using different page classes (inheriting from the WebDriverPage class),
so you can organize your classes (plus if you have different step
classes using the same page classes you can refactor step implementations)
On 04.08.2012 10:53, Roy de Kleijn wrote:
> I like to organize my steps in multiple class files. (because we have
> many steps in our application)
>
> Question is: how can we use the steps from multiple step definition
> classes to execute a single story.
>
> I use webdriver, I tried the following:
>
> BaseClass.java
> Instantiates the driver and opens the browser.
>
> LoginSteps.java inherit from BaseClass.java
> steps to login in application
>
> SearchSteps.java inherit from BaseClass.java
> Verify is elements is present.
> BUT here is my driver instance suddenly null.
>
> I think it has something to do with the way I execute my tests:
> <at> Override
> public InjectableStepsFactory stepsFactory() { return new
> InstanceStepsFactory(configuration(), new LoginSteps(), new
> searchPageSteps()); }
>
> Please tell what other information you need or what I have to do
> differently.
> Thanks
>
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email