Hi,

I am new to JBehave, and wondering how to set up the runner class to be
able to run the tests against multiple browsers.
Could anybody post the example?

This is the example of my class, which I run as Junit test (it kicks off
the Firefox):

public class ChannelRunner extends JUnitStories {


    private WebDriverProvider driverProvider = newPropertyWebDriverProvider();

    private WebDriverSteps lifecycleSteps = new PerStoriesWebDriverSteps(
driverProvider);

    private Pages pages = new Pages(driverProvider);

    private SeleniumContext context = new SeleniumContext();

    private ContextView contextView =
newLocalFrameContextView().sized(500, 100);



    public ChannelRunner() {

        if ( lifecycleSteps instanceof PerStoriesWebDriverSteps ){


configuredEmbedder().useExecutorService(MoreExecutors.sameThreadExecutor());

            configuredEmbedder().useMetaFilters(asList("-skip"));

        }

    }


    @Override

    public Configuration configuration() {

        Class<? extends Embeddable> embeddableClass = this.getClass();

        return new SeleniumConfiguration()

                .useSeleniumContext(context)

                .useWebDriverProvider(driverProvider)

                .useStepMonitor(new SeleniumStepMonitor(contextView, context,
new SilentStepMonitor()))

                .useStoryLoader(new LoadFromClasspath(embeddableClass))

                .useStoryReporterBuilder(new StoryReporterBuilder()


.withCodeLocation(codeLocationFromClass(embeddableClass))

                    .withDefaultFormats()

                    .withFormats(CONSOLE, TXT, HTML, XML));

    }


    @Override

    public InjectableStepsFactory stepsFactory() {

        Configuration configuration = configuration();

        return new InstanceStepsFactory(configuration,

                new ChannelCreateSteps(pages),

                lifecycleSteps,

                new WebDriverScreenshotOnFailure(driverProvider,
configuration.storyReporterBuilder()));

    }



    @Override

    protected List<String> storyPaths() {

        return new StoryFinder()

                .findPaths(codeLocationFromClass(this.getClass()).getFile(),
asList("**/*channel.story"), null);

    }


    public static class SameThreadEmbedder extends Embedder {



        public SameThreadEmbedder() {

            useExecutorService(MoreExecutors.sameThreadExecutor());

        }


    }

}

Thanks,
Paule Zaksauskiene,
QA Engineer

Reply via email to