Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 664
Gino Filicetti Avatar asked May 29 '12 21:05

Gino Filicetti


2 Answers

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);
like image 54
jokka Avatar answered Oct 25 '22 03:10

jokka


This should work:

driver.manage().window().setSize(new Dimension(800, 621));
like image 32
Stackcraft_noob Avatar answered Oct 25 '22 02:10

Stackcraft_noob