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 ....... > ........ > >
