Resizing

When we open a browser through Selenium, it will start with the default settings. Depending on our objective, it might be necessary to change the browser window size. For example, if we have a responsive web application, we might want to change the browser size to automatically check how the application behaves in different window sizes.

The WebDriver.Options manage() method is provided by the WebDriver class to resize windows during the execution of a script. The manage().window() interface includes methods that allow us to resize the windows.

Here are some of the methods provided by the manage().window() interface:

  • manage().window().maximize(): Maximizes the current window
  • manage().window().fullscreen(): Sets the current window to full screen size
  • manage().window().setPosition(new Point(50, 200)): Sets the position of the current window
  • manage().window().setSize(new Dimension(300, 500)): Sets the size of the current window
  • manage().window().getPosition(): Gets the position of the current window
  • manage().window().getSize(): Gets the size of the current window
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.118.95