From Selenium 2.21, we can now maximize the browser window, similar to Selenium RC.
Direct way:
Indirect way:
we can also maximize the browser window usingt the toolkit utility which query the native operating system directly and is platform independent. In addition to this, the code below will maximize the browser window according to your system's current resolution.
Direct way:
public static void main(String[] args) {WebDriver d = new FirefoxDriver();d.get("http://www.google.com"); d.manage().window().maximize();
System.out.println(d.getTitle()); d.quit();}
Indirect way:
we can also maximize the browser window usingt the toolkit utility which query the native operating system directly and is platform independent. In addition to this, the code below will maximize the browser window according to your system's current resolution.
driver.manage().window().setPosition(
new
Point(0,0));
java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
Dimension dim =
new
Dimension((int) screenSize.getWidth(), (int) screenSize.getHeight());
driver.manage().window().setSize(dim);
U
se the above script in your test setup method where you initiate the browser to get a fully maximized brwoser window that fits your monitor's screen size....