如何在多个浏览器上运行jBehave测试?

时间:2012-06-18 12:00:52

标签: internet-explorer google-chrome browser selenium jbehave

我目前在当前浏览器上运行JBehave Selenium测试,我使用PropertyWebDriverProvider()来设置我的浏览器。 有我的代码:

public class PlayerLandingPageRunner扩展了JUnitStories {

private WebDriverProvider driverProvider = new PropertyWebDriverProvider();
private WebDriverSteps lifecycleSteps = new PerStoriesWebDriverSteps(driverProvider);
private Pages pages = new Pages(driverProvider);
private SeleniumContext context = new SeleniumContext();
private ContextView contextView = new LocalFrameContextView().sized(500, 100);

public PlayerLandingPageRunner() {
    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));
}

...

如何将其设置为在其他浏览器上运行? IE,Chrome?

谢谢!

1 个答案:

答案 0 :(得分:2)

您应该使用here中描述的值之一将“browser”系统属性传递给JVM。

以下是设置测试以在Chrome上运行的方法。

如果您在命令行中运行,只需像这样传递

java -Dbrowser=chrome ...

如果您使用的是Eclipse,请打开运行配置,选择用于运行测试的配置并附加到 VM参数文本框-Dbrowser=chrome