[Selenium] Maxmize Web Browser Window Size

[Tips For Selenium]

Maxmize Web Browser Window Size

Firefox & IE

System.setProperty("webdriver.gecko.driver", "C:/webdriver/geckodriver64.exe");
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();

Chrome

ChromeOptions co = new ChromeOptions();
co.addArguments("--start-maximized");

System.setProperty("webdriver.chrome.driver", "C:/webdriver/chromedriver.exe");
WebDriver driver = new ChromeDriver(co);

Screen Capture

Chrome

Rectangle captureSize = new Rectangle(Toolkit.getDefaultToolkit().getScreenSize());
Robot robot = new Robot();
BufferedImage bufferedImage = robot.createScreenCapture(captureSize);
File file = new File("c:\\webdriver\\capturedImages\\capture1.png");
ImageIO.write(bufferedImage, "png", file);
Advertisements