39

How do we maximize a firefox browser using Selenium WebDriver (Selenium 2) with node.js. I am using wd package for Selenium WebDriver to write the tests. I have tried executing window.resizeTo(1366,768); usin eval or execute but didn't work.

I am using Selenium WebDriver 2.25.0

4
  • What version of webdriver are you on? Commented Dec 27, 2012 at 12:04
  • I'm using selenium webdriver 2.25.0 Commented Dec 27, 2012 at 12:53
  • I hope this post will helps you. stackoverflow.com/questions/3189430/… Commented Dec 28, 2012 at 14:02
  • 3
    Irrelevant to node.js, but just for googlers like me: in Python it is done by driver.maximize_window() Commented Aug 8, 2013 at 13:54

13 Answers 13

69

Have you tried :

driver.manage().window().maximize() 

Doc

Sign up to request clarification or add additional context in comments.

2 Comments

I'm using asynchronous style programming with node.js. I've tried to use it after the driver.init() call but it returns "TypeError: Object #<EventEmitter> has no method 'manage'"
If you're using capybara: page.driver.browser.manage.window.maximize (ie access selenium driver via page.driver.browser).
9

First instantiate a firefox driver

WebDriver driver = new FirefoxDriver();

then maximize it

 driver.manage().window().maximize();

Comments

6

Use this code:

driver.manage().window().maximize() 

works well,

Please make sure that you give enough time for the window to load before you declare this statement.

If you are finding any element to input some data then provide reasonable delay between this and the input statement.

Comments

4
driver.manage().window().maximize();

Comments

2

Try this working for Firefox:

driver.manage().window.maximize();

Comments

2

As of 2020, the correct answer is :

driver.maximize_window()

Comments

1

If you are using Selenium WebdriverJS than the below code should work:

var window = new webdriver.WebDriver.Window(driver);
window.maximize();

Comments

1

Call window as a function.

driver.manage().window().maximize();

Comments

1

The statement :: driver.manage().window.maximize(); Works perfectly, but the window maximizes only after loading the page on browser, it does not maximizes at the time of initializing the browser.

here : (driver) is called object of Firefox driver, it may be any thing depending on the initializing of Firefox object by you only.

1 Comment

What workaround do you recommend? I've checked that it works but not always.
1
driver.Manage().Window.Maximize(); 

Comments

1

Try this:

self.ff_driver = Firefox()
self.ff_driver.maximize_window()

Comments

1

One way, everyone already have written in thier answers:

driver.manage().window().maximize() 

but if you looking for alternative ways, here you are:

driver.manage().window().setSize(screenResolution);

or

driver.findElement(By.id("......")).sendKeys(Keys.F11);

Comments

0
driver.manage().window().maximize() ;

works perfectly and at the very beginning it maximizes the window. Does not wait to load any page.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.