```java
public static WebDriver getWebDriver(boolean proxy) {
String os = System.getProperty("os.name").toLowerCase();
ChromeOptions chromeOptions = new ChromeOptions();
chromeOptions.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"});
chromeOptions.setExperimentalOption("useAutomationExtension", false);
chromeOptions.addArguments("--disable-blink-features=AutomationControlled","--incognito","--disable-infobars","--user-agent="+getUa());
if (!os.contains("windows")) {
chromeOptions.addArguments("headless");
chromeOptions.addArguments("no-sandbox");
proxyadd = "localhost:3128";
System.setProperty("webdriver.chrome.driver", "/chromedriver/chromedriver");
} else {
proxyadd = "localhost:3128";
/*chromeOptions.addArguments("headless");
chromeOptions.addArguments("no-sandbox");*/
System.setProperty("webdriver.chrome.driver", "/chromedriver/chromedriver.exe");
}
if (proxy) {
//chromeOptions.addArguments("--proxy-server=http://localhost:3128");
Proxy proxy1 = new Proxy();
proxy1.setHttpProxy(proxyadd);
proxy1.setSslProxy(proxyadd);
chromeOptions.setCapability("proxy", proxy1);
//chromeOptions.addExtensions(new File("/chromedriver/proxy.zip"));
}
WebDriver webDriver = new ChromeDriver(chromeOptions);
webDriver.manage().window().maximize();
return webDriver;
}