1

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

公共类 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,铬?

谢谢!

4

1 回答 1

2

您应该使用此处描述的值之一将“浏览器”系统属性传递给 JVM 。

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

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

java -Dbrowser=chrome ...

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

于 2012-06-19T12:08:57.973 回答