I just ran the TraderStory and it turns out it seemed to work ok. I still will 
try the webdriver, since I want to use that, if possible.
The thing I probably have to pinpoint is if selenium is installed properly, 
since jbehave has been working perfectly.
Thanks, again.
From: [email protected]
To: [email protected]
Date: Fri, 15 Oct 2010 15:57:31 +0000
Subject: RE: [jbehave-user] running selenium/webdriver examples of jbehave-web








Mauro,

I tried the selenium example and had a big mess (lots of errors), but I haven't 
tried the webdriver example. I will try that now.
When I tried the selenium example, I manually created the files in Eclipse. Is 
there any easy way to import the webdriver example
into Eclipse?  Thanks!!

Date: Fri, 15 Oct 2010 17:50:41 +0200
From: [email protected]
To: [email protected]
Subject: Re: [jbehave-user] re: puzzled about java runtime error in 
introductory tutorial jbehave 3 example



  


    
  
  
    Have you tried running the selenium and/or webdriver examples of
    jbehave-web? 

    

http://git.codehaus.org/gitweb.cgi?p=jbehave-web.git;a=tree;f=examples

    

    http://jbehave.org/reference/web/preview/using-selenium.html

    

    On 15/10/2010 17:38, entfred smith wrote:
    
      
      Hello,

      

      I am trying to get a variation of the jbehave 3 example in the
      introductory tutorial working.  The code is below and is fairly
      simple.

      

      http://jbehave.org/reference/stable/getting-started.html

      

      I am getting the following junit runtime

      error when I try to run the program. Thanks for any advice on
      debugging this problem:

      

      java.lang.NoClassDefFoundError: org/openqa/selenium/Capabilities

      at
org.jbehave.web.selenium.SeleniumConfiguration.defaultSelenium(SeleniumConfiguration.java:43)

      at
org.jbehave.web.selenium.SeleniumSteps.<init>(SeleniumSteps.java:18)

      

      My programs look like this:

      

      package test.scenarios.gettingStarted;

      

      import java.util.List;

      

      import org.jbehave.core.configuration.Configuration;

      import org.jbehave.core.configuration.MostUsefulConfiguration;

      import org.jbehave.core.io.LoadFromClasspath;

      import org.jbehave.core.junit.JUnitStory;

      import org.jbehave.core.reporters.StoryReporterBuilder;

      import org.jbehave.core.reporters.StoryReporterBuilder.Format;

      import org.jbehave.core.steps.CandidateSteps;

      import org.jbehave.core.steps.InstanceStepsFactory;

      import org.openqa.selenium.*;

      

      public class Test extends JUnitStory {

      

          // Here we specify the configuration, starting from default

          // MostUsefulConfiguration, and changing only what is needed

          @Override

          public Configuration configuration() {

              return new MostUsefulConfiguration()

              // where to find the stories

                      .useStoryLoader(

                              new
      LoadFromClasspath(this.getClass().getClassLoader()))

                      // CONSOLE and TXT reporting

                      .useStoryReporterBuilder(

                              new
      StoryReporterBuilder().withDefaultFormats()

                                      .withFormats(Format.CONSOLE,
      Format.TXT));

          }

      

          // Here we specify the steps classes

          @Override

          public List<CandidateSteps> candidateSteps() {

              // varargs, can have more that one steps classes

              return new InstanceStepsFactory(configuration(), new
      TestSteps())

                      .createCandidateSteps();

          }

      }

      

      =====================

      

      package test.scenarios.gettingStarted;

      

      import org.jbehave.core.annotations.Alias;

      import org.jbehave.core.annotations.Aliases;

      import org.jbehave.core.annotations.Given;

      import org.jbehave.core.annotations.Named;

      import org.jbehave.core.annotations.Then;

      import org.jbehave.core.annotations.When;

      

      import com.thoughtworks.selenium.Selenium;

      import com.thoughtworks.selenium.condition.Condition;

      import
      com.thoughtworks.selenium.condition.ConditionRunner.Context;

      

      public class TestSteps extends
      org.jbehave.web.selenium.SeleniumSteps {

      

         

          String url = null;

          String contextRoot = "/test";

      

          public TestSteps(Selenium selenium) {

              super(selenium);

          }

      

          public TestSteps() {

              // TODO Auto-generated constructor stub

          }

      

         

      

          @When("I type \"<text>\" into <field>")

          @Aliases(values = { "I type \"$text\" into $field" })

          public void type(@Named("text") String text, @Named("field")
      String field) {

              if (field.contains(".")) {

                  field = String.format("xpath=//inp...@id='%s']",
      field);

              }

              selenium.type(field, text);

          }

      

          

          @Then("I should see \"<message>\"")

          @Alias("I should see \"$message\"")

          public void shouldSee(@Named("message") String message) {

              url = selenium.getLocation();

              // System.out.println(" should see url = " + url);

          }

      

        

          @Given("I am not logged in")

          public void nobodyLoggedIn() {

              selenium.start();

              selenium.open("http://localhost:8080/test/test.html";);

              selenium.waitForPageToLoad(timeout);

             ;

          };

          

         

      

      }

      

      test.story is just a normal junit test:

      

      Given I am not logged in

      When I log in as .......

      Then I should see .......

      ........

      

      

    
    
                                          

Reply via email to