package interview_practice;
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Set_Get_WindowPosition_Size {
WebDriver driver;
@BeforeTest
public void setup() throws Exception {
driver = new FirefoxDriver();
driver.manage().window().maximize();
}
@Test(priority=0)
public void setWindowSizePosition()
{
driver.get("http://www.google.com");
//WebDriver setSize method used to set window size width = 300 and height = 500.
driver.manage().window().setSize(new Dimension(300, 500));
//WebDriver getSize method used to get window width and height
Dimension getWinSize=driver.manage().window().getSize();
System.out.println("current view of window hight size is :" + getWinSize.getHeight());
System.out.println("current view of window Width size is :" + getWinSize.getWidth());
}
@Test(priority=1)
public void setWindowPosition()
{
driver.manage().window().setPosition(new Point(50, 200));
Point getWinSize=driver.manage().window().getPosition();
System.out.println("current view of window hight size is :" + getWinSize.getX());
System.out.println("current view of window Width size is :" + getWinSize.getY());
}
@AfterTest
public void tearDown() throws Exception
{
driver.close();
}
}
+++++++++++++Change window position+++++++++++
package All_Types_Run;
import java.awt.AWTException;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Change_Window_Position
{
public static void main(String[] args) throws InterruptedException, AWTException
{
WebDriver driver = new FirefoxDriver();
driver.get("http:\\google.com");
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
}
}
import org.openqa.selenium.Dimension;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;
public class Set_Get_WindowPosition_Size {
WebDriver driver;
@BeforeTest
public void setup() throws Exception {
driver = new FirefoxDriver();
driver.manage().window().maximize();
}
@Test(priority=0)
public void setWindowSizePosition()
{
driver.get("http://www.google.com");
//WebDriver setSize method used to set window size width = 300 and height = 500.
driver.manage().window().setSize(new Dimension(300, 500));
//WebDriver getSize method used to get window width and height
Dimension getWinSize=driver.manage().window().getSize();
System.out.println("current view of window hight size is :" + getWinSize.getHeight());
System.out.println("current view of window Width size is :" + getWinSize.getWidth());
}
@Test(priority=1)
public void setWindowPosition()
{
driver.manage().window().setPosition(new Point(50, 200));
Point getWinSize=driver.manage().window().getPosition();
System.out.println("current view of window hight size is :" + getWinSize.getX());
System.out.println("current view of window Width size is :" + getWinSize.getY());
}
@AfterTest
public void tearDown() throws Exception
{
driver.close();
}
}
+++++++++++++Change window position+++++++++++
package All_Types_Run;
import java.awt.AWTException;
import org.openqa.selenium.Point;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
public class Change_Window_Position
{
public static void main(String[] args) throws InterruptedException, AWTException
{
WebDriver driver = new FirefoxDriver();
driver.get("http:\\google.com");
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