Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

Why syntax is driver.manage().window().maximize()?

Posted on 03/16/2025 By admin

We frequently used the below kinds of method chaining statements in Selenium WebDriver scripts. This is a frequently asked interview question as well and you may be asked to explain the syntax. We are going to learn the same here.

driver.manage().window().maximize(); // To maxmize
driver.navigate().to("some url"); // To open url
driver.manage().timeouts().implicitlyWait(30, TimeUnit.SECONDS);// To set implicit time

Did you know that I have started a YouTube channel as well and I need your support to make it successful. Please do watch content then comment, like, share, and obviously subscribe.

The above syntaxes are written using Method Chaining concepts of Java. Let’s learn the method chaining concept with a simple Java example.

We have three class as below:-

class NewDemo
{
        void NewDemoMethod()
        {
                System.out.println("NewDemoMethod");
        }
        
}

This class has a method that returns a type reference of NewDemo class ( First one).

class AnotherDemo
{
        public NewDemo AnotherDemoMethod()
        {
                System.out.println("AnotherDemoMethod");
                return new NewDemo();
        }       
}

This class has a method that returns a type of AnotherDemo. (Second class).

public class Demo {

  // A method with return type AnotherDemo
  public AnotherDemo DemoMethod() {
    System.out.println("DemoMethod");
    return new AnotherDemo();
  }

  public static void main(String[] args) {
    // Creating an object of Demo class
    Demo DemoObject = new Demo();
    // Calling DemoMethod() that returns a type of AnotherDemo and storing its return value 
    AnotherDemo AnotherDemoObject = DemoObject.DemoMethod();
    // Since we have a reference of AnotherDemo then we can call method of AnotherDemo
    NewDemo NewDemoObject = AnotherDemoObject.AnotherDemoMethod();
    NewDemoObject.NewDemoMethod();

    // method chaining
    Demo DemoObject1 = new Demo();
    DemoObject1.DemoMethod().AnotherDemoMethod().NewDemoMethod(); // Method chaining

  }
}

1. There is a total of three classes “Demo“, “AnotherDemo” and “NewDemo“.
2. Class “Demo” has a method “DemoMethod” that returns an object or type of class “AnotherDemo“.
3. Class “AnotherDemo” has a method “AnotherDemoMethod” that returns an object of class “NewDemo“.
4. Class “NewDemo” has a method “NewDemoMethod” that returns void.

5. You can understand from the above steps that all three classes are connected or a point of connection. 6. Class “Demo” has a main method and we will write call methods here.

7. We created an object of “Demo” that enables us to call its method “DemoMethod()” that returns an object of class “AnotherDemo“. We can store the return type of a method in an appropriate type and here we can use a reference variable of type “AnotherDemo“.

Uncategorized

Post navigation

Previous Post: Part 7: Usages Of Javascripts In Selenium: Difference Among ScrollBy, ScrollTo and Scroll Methods Of Javascript
Next Post: REST Assured Tutorial 33 – De-Serialization – JSON Object To Java Object Using Jackson API

Related Posts

January 9, 2019 – Make Selenium Easy Uncategorized
How Page Factory In Selenium WebDriver Performs Lazy Initialization Uncategorized
January 10, 2018 – Make Selenium Easy Uncategorized
image – Make Selenium Easy Uncategorized
image – Make Selenium Easy Uncategorized
December 26, 2018 – Make Selenium Easy Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark