Hey @Misha, you can use this code snippet to check whether internet is connected or not:
WebDriver driver = new ChromeDriver();
driver.manage().window().maximize();
driver.manage().timeouts().implicitlyWait(5, TimeUnit.SECONDS);
driver.navigate().to("https://www.google.com");
WebElement error = driver.findElement(By.className("error-code"));
if(error.getText().equals("DNS_PROBE_FINISHED_NO_INTERNET") || error.getText().equals("ERR_NAME_NOT_RESOLVED")) {
System.out.println("No Internet Connection");
} else {
System.out.println("Internet Connected");
}
driver.close();