Hi Mauro,
thanks for your reply (grazie),

Say I have a simple google.story

Sceanrio: Google
Given I am on google.com
When I search for 'jbehave'
Then I should see 'jbehave.org'

How would GoogleSteps.java and Google.java look like when I want to drive my 
tests with selenium from within Eclipse (JUnit Runner)? 

Thanks
Clemens
-------- Original-Nachricht --------
> Datum: Sat, 31 Jul 2010 11:14:01 +0200
> Von: Mauro Talevi <[email protected]>
> An: [email protected]
> Betreff: [jbehave-user] Re: JBehave 3 with Selenium (in Eclipse) - example?

> Hi Clemens,
> 
> first off, welcome to JBehave world!
> 
> One thing I've noticed is that you were extending SeleniumPerStorySteps
> (which extends Steps) but then using the InstanceStepsFactory.  I've now
> made the Selenium Steps classes POJOs and thus can be used with the
> factory.   Please try pulling latest master snapshot.
> 
> Also, the point of extending the Selenium Steps classes is that they
> provide the Selenium instance and start/stop it for you.  If you want to
> do that yourself (in your constitutional right as a JBehaver! :-) you
> don't need to extend any class.
> 
> In general, it'd be useful if you could provide us with the full source
> code of your example, in a zip file, so we can try to reproduce issues.
> 
> Cheers
> 
> On 31/07/2010 09:53, Clemens Wyss wrote:
> > Coming from Rails/cucumber I am very pleased to find JBehave in the Java
> world :-)
> > I am trying to get my JBehave 3/Selenium tests running, but weird things
> happen with selenium (startup). selenium starts up BUT weird URLS (file
> paths) are being sent. I have "plain" selenium test (SeleneseTestCase) which
> run, i.e. selenium et al are setup correctly.
> > 
> > I guess it has to do with the @BeforeStory/@AfterStory...?
> > 
> > I have 
> > 
> > i_can_login.story:
> > -------------------
> > 
> > Scenario: User can login
> > 
> > Given nobody is logged in
> > When I login as 'clemens' with password 'pw'
> > Then I should see 'Clemens Wyss'
> > 
> > 
> > ICanLogin.java:
> > ------------------
> > package ch.mysign.integrationtests;
> > 
> > import org.jbehave.core.JUnitStory;
> > import org.jbehave.core.configuration.Configuration;
> > import org.jbehave.core.configuration.MostUsefulConfiguration;
> > import org.jbehave.core.io.LoadFromClasspath;
> > import org.jbehave.core.io.UnderscoredCamelCaseResolver;
> > import org.jbehave.core.reporters.StoryReporterBuilder;
> > import org.jbehave.core.steps.InstanceStepsFactory;
> > import org.junit.Test;
> > 
> > public class ICanLogin extends JUnitStory
> > {
> >  public ICanLogin ()
> >  {
> >  ClassLoader classLoader = this.getClass().getClassLoader();
> >  Configuration configuration = new MostUsefulConfiguration()
> >  .useStoryPathResolver(new UnderscoredCamelCaseResolver(".story"))
> >  .useStoryLoader( new LoadFromClasspath(classLoader) )
> >  .useStoryReporterBuilder(new StoryReporterBuilder()
> >  .withDefaultFormats()
> >  .withFailureTrace(false)
> >  );
> >  useConfiguration(configuration);
> >  addSteps( new InstanceStepsFactory( configuration, new
> SeleniumLoginSteps() )
> >  .createCandidateSteps() ); // varargs, can have lots of steps
> >  }
> > 
> >  @Test
> >  public void runScenario () throws Throwable
> >  {
> >  super.run();
> >  } 
> > }
> > 
> > SeleniumLoginSteps.java:
> > ----------------------------
> > package ch.mysign.integrationtests;
> > 
> > import junit.framework.Assert;
> > 
> > import org.jbehave.core.annotations.AfterStory;
> > import org.jbehave.core.annotations.BeforeStory;
> > import org.jbehave.core.annotations.Given;
> > import org.jbehave.core.annotations.Then;
> > import org.jbehave.core.annotations.When;
> > import org.jbehave.web.selenium.SeleniumPerStorySteps;
> > 
> > import com.thoughtworks.selenium.DefaultSelenium;
> > import com.thoughtworks.selenium.Selenium;
> > 
> > public class SeleniumLoginSteps extends SeleniumPerStorySteps
> > {
> >  static int EMBEDDED_TOMCAT_PORT = 8080;
> >  static int SELENIUM_PORT = 4444;
> >  private Selenium selenium = null;
> > 
> >  @BeforeStory
> >  public void setupSelenium()
> >  {
> >  selenium = new DefaultSelenium( "localhost", SELENIUM_PORT,
> "*iexplore", "http://localhost:"; + EMBEDDED_TOMCAT_PORT + "/" );
> >  selenium.start();
> >  }
> > 
> >  @AfterStory
> >  public void tearDownSelenium()
> >  {
> >  selenium.close();
> >  }
> > 
> >  @Given("nobody is loged in")
> >  public void nobodyIsLoggedIn()
> >  {
> >  AdminLoginPage.logout( selenium );
> >  }
> > 
> >  @When("I login as '$username' with password '$password'")
> >  public void loginAs(String username, String password)
> >  {
> >  AdminLoginPage.loginAs( selenium, username, password );
> >  }
> > 
> >  @Then("I should see '$seen'")
> >  public void iShouldSee(String seen)
> >  {
> >  Assert.assertTrue( selenium.isTextPresent( seen ) );
> >  }
> > 
> > }
> > ----------
> > I also looked (and adapted)
> http://jbehave.org/reference/latest/running-stories.html, but this code does 
> not compile (StoryFinder, asList,
> storyClass). 
> > 
> > 
> > So my question is: can anybody provide a JBehave 3/Selenium example
> which for example makes a google search?
> > 
> > 
> > Thx in advance
> > Clemens
> > 
> > ---------------------------------------------------------------------
> > 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
> 
> 

-- 
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!  
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply via email to