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

白昼怎懂夜的黑 提交于 2019-12-04 06:08:36

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);

What jokka said is correct, justr a side note: Before resizing window, I always put it to top left corner, so I know that WebDriver can "see" everything:

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

Obviously, the driver above is assumed healthy instance of WebDriverProvider

Gino Filicetti

We ended up finding this Chrome Driver and it's been working great. It can take a parameter when it is bootstrapped to start in maximized mode and also exposes the capability to add extensions when it starts up.

This should work:

driver.manage().window().setSize(new Dimension(800, 621));
driver.Manage().Window.Size = new Size(x, y);

This works fine for me. The x and y are in a feature file.

Try this:

This is working fine for me.

Capybara.current_session.driver.browser.manage.window.resize_to(1800, 1000)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!