Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Selenium Webdriver - Set browser width and height

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 789
    Comment on it

    Here, we discuss that how to resize the browser's width and height in Selenium WebDriver. It allows to resize and also maximize the window from its API. In this, Dimension Class helps to resize and declare the object by initializing the width and height.


    Also, we need to import:

    'import org.openqa.selenium.Dimension'



    Steps to be automated:


    • Launch the browser
    • Open your site
    • Navigate to your required location
    • Resize the browser width and height



    WebDriver Code goes as below:


    import java.util.concurrent.TimeUnit;
    import org.openqa.selenium.By;
    import org.openqa.selenium.Dimension;
    import org.openqa.selenium.WebDriver;
    import org.openqa.selenium.WebElement;
    import org.openqa.selenium.firefox.FirefoxDriver;
    public class ResizeWindow {
    	public static void main(String[] args) throws InterruptedException {
            WebDriver driver = new FirefoxDriver();
    		driver.manage().timeouts().implicitlyWait(20L, TimeUnit.SECONDS);
    		WebElement textField = driver.findElement(By.xpath(".//*[@id='sb_ifc0']"));;
    		Dimension d = new Dimension(420,600);
    		Dimension d1 = new Dimension(520,700);




 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: