Setting browser width and height in Selenium Web Driver

0 votes

I am writing test cases in Selenium WebDriver using Python. I want to 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 it 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:

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

But I don't know what foo is, and I can't figure out where the docs are.

Jul 19, 2018 in Selenium by Sahiti
• 6,370 points
1,161 views

1 answer to this question.

0 votes

For me, the only thing that worked in Java 7 on OS X 10.9 is shown below:

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

Where 1014 is the width, and 738 is the height.

answered Jul 19, 2018 by Meci Matt
• 9,460 points

Related Questions In Selenium

0 votes
1 answer

How do i change the location where my file gets downloaded in Selenium Webdriver and firefox driver?

There are a couple of errors there. ...READ MORE

answered Apr 13, 2018 in Selenium by nsv999
• 5,500 points
6,191 views
0 votes
0 answers

How to Create Object Repository in Selenium Web Driver?

I wanted to know how to create ...READ MORE

Apr 17, 2018 in Selenium by Shubham
• 13,490 points
1,966 views
0 votes
1 answer

Matching different browser version and selenium driver version

Look at the below link to see ...READ MORE

answered Jun 21, 2018 in Selenium by Samarpit
• 5,910 points
2,735 views
0 votes
3 answers

How to click the search button using Selenium web driver and Python

You can try with tag. #this code will ...READ MORE

answered Apr 10, 2019 in Selenium by Matin
16,244 views
0 votes
1 answer

Installing Selenium Webdriver with Python package

Hey Hemant, for installing Selenium Webdriver with ...READ MORE

answered May 8, 2019 in Selenium by Anvi
• 14,150 points
15,838 views
0 votes
2 answers

Finding WebDriver element with Class Name in java

The better way to handle this element ...READ MORE

answered Apr 10, 2018 in Selenium by nsv999
• 5,500 points
13,674 views
0 votes
2 answers

Problem while using InternetExplorerDriver in Selenium WebDriver

enable trusted connection  in internet explorer by ...READ MORE

answered Aug 31, 2020 in Selenium by Sri
• 3,190 points
9,143 views
0 votes
1 answer

Geo-location microphone camera pop up

To Allow or Block the notification, access using Selenium and you have to ...READ MORE

answered May 11, 2018 in Selenium by Samarpit
• 5,910 points
7,221 views
0 votes
2 answers

Get text using selenium web driver in python

text = driver.find_element_by_class_name("current-text").getText(); ...READ MORE

answered Feb 4, 2019 in Selenium by anonymous
38,101 views
0 votes
1 answer

Opening Browser in Selenium

Here is the code to open the ...READ MORE

answered Apr 20, 2018 in Selenium by Meci Matt
• 9,460 points
615 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP