How to resize browser window when starting FirefoxWebDriverProvider in JBehave Web

We use the JBehave Web to manage our selenium test suite for the new project and is very similar to the Etsy.com example available on JBehave, especially the Java / Spring maven archetype, as it fits our architecture.

The biggest problem so far has been documentation, so I post here hoping that I can get help from others in a similar situation.

It seems that JBehave Web provides only the "FirefoxWebDriverProvider" class and does not match the one for Chrome. Anyone else run into this issue? Have you written your own ChromeDriverProvider?

In addition, we need to resize the browser, which appears by default, and I cannot find a way to do this during the initial loading of the test run.

We use the Maven archetype: jbehave-web-selenium-java-spring-archetype, which uses the jbehave-maven-plugin and the run-stories-with-annotated-embedder target, so we use the Annotated method to extend InjectableEmbedder.

If someone can give some recommendations, I would really appreciate it, even if I just point out more examples.

+6
source share
6 answers

How to resize a window

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

You can easily find such a code by going through the code. If you use Eclipse, the Open Declaration and Quick Type Hierarchy options are all you need.

How to use the Chrome driver

You can use TypeWebDriverProvider or PropertyWebDriverProvider . For instance:

 new TypeWebDriverProvider(ChromeDriver.class); 
+12
source

What jokka said correctly is justr side note: before resizing the window, I always put it in the upper left corner, so I know that WebDriver can “see” everything:

 driver.get().manage().window().setPosition(new Point(0, 0)); 

Obviously, the driver above is considered a healthy instance of WebDriverProvider

+3
source

In the end, we discovered this Chrome Driver , and it works great. It can take a parameter when it is loaded to run in maximized mode, and also provides the ability to add extensions at startup.

+2
source
 driver.Manage().Window.Size = new Size(x, y); 

This works great for me. X and y are in the function file.

+1
source

Try the following:

This works great for me.

 Capybara.current_session.driver.browser.manage.window.resize_to(1800, 1000) 
0
source

This should work:

 driver.manage().window().setSize(new Dimension(800, 621)); 
0
source

Source: https://habr.com/ru/post/916952/