Totti
Totti

Reputation: 5

Can't maximize browser window by using selenium webDriver on local MAC machine

I"m trying to maximize browser window by using this Java code:

webDriver.manage().window().maximize();

Is there any other option for this operation?

Upvotes: 0

Views: 699

Answers (2)

MikeJRamsey56
MikeJRamsey56

Reputation: 2819

Try using the Toolkit utility.

import java.awt.Toolkit;
import org.junit.Test;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.remote.DesiredCapabilities;

public class MaximizeBrowser {

    @Test
    public void test()
    {

        WebDriver driver = new FirefoxDriver();

        Toolkit toolkit = Toolkit.getDefaultToolkit();
        int Width = (int) toolkit.getScreenSize().getWidth();
        int Height = (int)toolkit.getScreenSize().getHeight();
        //For Dimension class, Import following library "org.openqa.selenium.Dimension"  
        driver.manage().window().setSize(new Dimension(Width,Height));
        // Your code here
        driver.quit();
        }


}

Upvotes: 1

djangofan
djangofan

Reputation: 29669

Sounds like your trying to call a native driver method on Firefox when you need to use Firefox 31.6.0 ESR , because later versions of Firefox don't support native. To work around this, use Chrome instead.

Upvotes: 0

Related Questions