How to manipulate the browser window?

É possível manipular a janela do navegador? como por exemplo, redimensionar o tamanho da janela e colocar ela em uma local especifico da tela, como no canto da tela

Is it possible to manipulate the browser window? such as resizing the window size and placing it in a specific location on the screen, such as in the corner of the screen

Yes, it’s possible.

These methods should allow you to position the browser:

public class Browser {

  static void moveBrowser(int x, int y) {
    WebDriver driver = DriverFactory.getWebDriver()
    Capabilities cap = ((SmartWaitWebDriver) driver).getCapabilities()
    String browserName =  cap.getBrowserName()
    // Because IE is poo
    if(browserName != "internet explorer") {
      driver.manage().window().setPosition(new Point(x, y))
    }
  }

  static void sizeBrowser(int w, int h) {
    WebDriver driver = DriverFactory.getWebDriver()
    Dimension d = new Dimension(w, h)
    driver.manage().window().setSize(d)
  }

}

These are the imports - you should check them using Ctrl-Shift-O

import org.openqa.selenium.Capabilities
import org.openqa.selenium.Dimension
import org.openqa.selenium.Point
import org.openqa.selenium.WebDriver as WebDriver
import com.kms.katalon.core.webui.driver.DriverFactory as DriverFactory
import org.openqa.selenium.remote.RemoteWebDriver
import com.kms.katalon.core.webui.driver.SmartWaitWebDriver

You can add a class to your Katalon project by following this guide:

1 Like