How to change the size of the browser window when running the FirefoxWebDriverProvider in JBehave Web

Gino Filicetti picture Gino Filicetti · May 29, 2012 · Viewed 26.4k times · Source

We're using JBehave Web to drive our selenium test suite for a new project and really like the Etsy.com example available on JBehave, especially the Java/Spring maven archetype as this fits in with our architecture.

The biggest problem so far has been documentation, which is why I'm posting here in the hopes that I can get some help from others in a similar situation.

It looks like JBehave Web only provides a "FirefoxWebDriverProvider" class and no corresponding one for Chrome. Has anyone else run into this problem? Have you written your own ChromeDriverProvider?

Also, we need to change the size of the browser that comes up by default and I can't seem to find a way of doing that during the bootstrapping of the test run.

We're using the Maven archetype: jbehave-web-selenium-java-spring-archetype which uses the jbehave-maven-plugin and the "run-stories-with-annotated-embedder" goal so we're using the "Annotated" method of extending the InjectableEmbedder.

If anyone can provide some guidance, I'd really appreciate it, even if just pointers to more examples.

Answer

jokka picture jokka · Jun 20, 2012

How To Resize Window

webDriverProvider.get().manage().window().setSize(new Dimension(width, height));

You can easily find code like this by navigating through the code. If you are using Eclipse, Open Declaration and Quick Type Hierarchy options are everything you need.

How to Use Chrome Driver

You can use TypeWebDriverProvider or PropertyWebDriverProvider. For instance:

new TypeWebDriverProvider(ChromeDriver.class);