[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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s