How do I set browser width and height in Selenium WebDriver?

0
0

I’m using Selenium WebDriver for Python.
I want instantiate the browser with a specific width and height. So far the closest I can get is:

driver = webdriver.Firefox()
driver
.set_window_size(1080,800)

Which works, but sets the browser size after it is created, and I want it set at instantiation. I’m guessing there is an approach along the lines of:

profile = webdriver.FirefoxProfile();
profile
.set_preference(foo, 1080)
driver
= webdriver.Firefox(profile)

But I don’t know what foo would be, and I can’t figure out where the docs are.

Q1: is there a way to set width / height at instantiation?

Q2: Where are the reference docs listing all keys usable by profile.set_preference?

  • You must to post comments
0
0

For me, the only thing that worked in Java 7 on OS X 10.9 was this:

// driver = new RemoteWebDriver(new URL(grid), capability);
driver
.manage().window().setPosition(new Point(0,0));
driver
.manage().window().setSize(new Dimension(1024,768));

Where 1024 is the width, and 768 is the height.

  • You must to post comments
Showing 1 result
Your Answer
Post as a guest by filling out the fields below or if you already have an account.
Name*
E-mail*
Website