...5//import org.openqa.selenium.By;6//import org.openqa.selenium.WindowType;7//import org.openqa.selenium.chrome.ChromeDriver;8//import org.openqa.selenium.devtools.Console;9//import org.openqa.selenium.devtools.DevTools;10//import org.openqa.selenium.devtools.inspector.Inspector;11//import org.openqa.selenium.devtools.network.Network;12//import org.openqa.selenium.devtools.network.model.BlockedReason;13//import org.openqa.selenium.devtools.network.model.ConnectionType;14//import org.openqa.selenium.devtools.network.model.ResourceType;15//import org.openqa.selenium.devtools.target.Target;16//import org.openqa.selenium.devtools.target.model.TargetInfo;17//18//import java.util.Optional;19//import java.util.Set;20//21//import static org.junit.Assert.assertEquals;22//import static org.openqa.selenium.devtools.inspector.Inspector.detached;23//import static org.openqa.selenium.devtools.network.Network.emulateNetworkConditions;24//import static org.openqa.selenium.devtools.network.Network.loadingFailed;25//import static org.openqa.selenium.devtools.target.Target.attachToTarget;26//import static org.openqa.selenium.support.locators.RelativeLocator.withTagName;27//28//public class Main {29//30// public static void main(String[] args) {31//32// //Selenium 433// System.setProperty("webdriver.chrome.driver", "/Users/karthikkk/ChromeDriver/chromedriver");34// var chromeDriver = new ChromeDriver();35//36// var chromeDevTools = chromeDriver.getDevTools();37// //Session of ChromeDevTool38// chromeDevTools.createSession();39//40// //Enable Network offline41// enableNetworkOffline(chromeDevTools);42//43// //Enable Network Online44// enableNetworkOnline(chromeDevTools);45//46// //Network Interception47// interceptNetwork(chromeDevTools);48//49// //Inspect Detached network50// inspectDetached(chromeDevTools);51//52// //Console Log53// String message = "From ExecuteAutomation";54// consoleLogs(chromeDevTools, message);55// chromeDriver.executeScript("console.log('" + message + "');");56//57//58// chromeDriver.get("https://amazon.in");59//60// }61//62//63// /**64// * Enable Network Offline65// * @param devTools66// */67// private static void enableNetworkOffline(DevTools devTools) {68// devTools.send(Network.enable(Optional.of(100000000), Optional.empty(), Optional.empty()));69//70// devTools.send(emulateNetworkConditions(true, 100, 1000, 2000,71// Optional.of(ConnectionType.cellular3g)));72//73// devTools.addListener(loadingFailed(), loadingFailed -> assertEquals(loadingFailed.getErrorText(), "net::ERR_INTERNET_DISCONNECTED"));74// }75//76// /**77// * Enable Network Online78// * @param devTools79// */80// private static void enableNetworkOnline(DevTools devTools) {81// devTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));82//83// devTools.send(emulateNetworkConditions(false, 100, 5000, 2000,84// Optional.of(ConnectionType.cellular4g)));85//86// }87//88//89// /**90// * Intercept Network91// * @param chromeDevTools92// */93// private static void interceptNetwork(DevTools chromeDevTools) {94// chromeDevTools.send(Network.enable(Optional.empty(), Optional.empty(), Optional.empty()));95//96// //set blocked URL patterns97// chromeDevTools.send(Network.setBlockedURLs(ImmutableList.of("*.css", "*.jpg")));98//99// //add event listener to verify that css and png are blocked100// chromeDevTools.addListener(loadingFailed(), loadingFailed -> {101//102// if (loadingFailed.getResourceType().equals(ResourceType.Stylesheet)) {103// assertEquals(loadingFailed.getBlockedReason(), BlockedReason.inspector);104// }105//106// else if (loadingFailed.getResourceType().equals(ResourceType.Image)) {107// assertEquals(loadingFailed.getBlockedReason(), BlockedReason.mixedContent);108// }109//110// });111// }112//113// /**114// * Inspect Detached Network115// * @param devTools116// */117// private static void inspectDetached(DevTools devTools) {118// devTools.addListener(detached(), Assert::assertNotNull);119// devTools.send(Inspector.enable());120// Set<TargetInfo> targetInfos = devTools.send(Target.getTargets());121// targetInfos.forEach(122// targetInfo -> {123// var sessionId = devTools.send(attachToTarget(targetInfo.getTargetId(), Optional.of(false)));124// devTools.send(125// Target.sendMessageToTarget(126// "{\"method\":\"Page.crash\"}",127// Optional.of(sessionId),128// Optional.of(targetInfo.getTargetId())));129// });130// devTools.send(Inspector.disable());131// }132//133//134// /**135// * Get Console Logs136// * @param chromeDevTools137// * @param message138// */139// private static void consoleLogs(DevTools chromeDevTools, String message) {140//141// chromeDevTools.send(Console.enable());142//143// //add listener to verify the console message144// chromeDevTools.addListener(Console.messageAdded(), consoleMessageFromDevTools ->145// assertEquals(true, consoleMessageFromDevTools.getText().equals(message)));146//147// }148//149// /**150// * Selenium Misc features151// * @param chromeDriver152// */153// private static void Selenium4MiscFetures(ChromeDriver chromeDriver){154//155// // New Tab156// var newTab = chromeDriver.switchTo().newWindow(WindowType.TAB);157// newTab.get("http://executeautomation.com/demosite/Login.html");158//159// //login...