Tuesday, 21 June 2016

Resizing and moving browser window in Selenium

To resize the browser window, we can use below line. Dimension constructor takes 2 parameters - Height and width of the window.

driver.manage().window().setSize(new Dimension(100,100));

To set the browser window position, you can use below line of code. Point constructor takes 2 parameters - X and Y co-ordinates of the browser window. Below statement will move the window down by 200 pixel.

driver.manage().window().setPosition(new Point(0,200));

To maximize window, you can use below line of code.

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

What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Buy Best Selenium Books

Contributors