Thursday, May 15, 2014

How to change the position of the open browser window.

Note - use command -> driver.manage().window().setPosition(new Point(int value1,int value2));

import java.awt.AWTException;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;

public class MoveWindow
{
public static void main(String[] args) throws InterruptedException, AWTException
{
    WebDriver driver = new FirefoxDriver();
    driver.manage().window().setPosition(new Point(0,0)); //move the window to top right corner
    Thread.sleep(2000);
    driver.manage().window().setPosition(new Point(500,400)); //move the window to 500unit horizontally and 400unit vertical
}
}

No comments:

Post a Comment