Previously we saw how to launch any website in fullscreen mode, in this post, I’m gonna show you how to launch your chrome browser in fullscreen mode using ChromeOptions class method.

Step by Step Approach

Step1: Instantiate ChromeOptions Class
ChromeOptions co = new ChromeOptions();
Step2: Pass “–start-fullscreen” argument to “addArguments” method of ChromeOptions Class.
co.addArguments("--start-fullscreen");
Step: Pass the ChromeOptions object as an argument to ChromeDriver() – Constructor.
WebDriver driver = new ChromeDriver(co);

package fullscreendemo;

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
public class ChromeFullScreen 
{

	public static void main(String[] args) throws InterruptedException 
	{
		// set chromedriver path
		System.setProperty("webdriver.chrome.driver", "D:\\browser-drivers\\chromedriver.exe");
		// instantiate object to ChromeDriver class
		ChromeOptions co = new ChromeOptions();
		co.addArguments("--start-fullscreen");
		// instantiate object
		WebDriver driver = new ChromeDriver(co);
		// launch website
		driver.get("https://www.walmart.com/");
		// wait for sometime
		Thread.sleep(2000);
		// quit browser
		driver.quit();
	}

}