Created
November 2, 2021 22:55
-
-
Save jimevans/d573a1862aafa5cb7bda00f645ab40b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IWebDriver driver = new RemoteWebDriver(new Uri("http://localhost:4444"), new ChromeOptions()); | |
ICustomDriverCommandExecutor customCommandDriver = driver as ICustomDriverCommandExecutor; | |
customCommandDriver.RegisterCustomDriverCommands(ChromeDriver.CustomCommandDefinitions); | |
ChromiumNetworkConditions networkConditions = new ChromiumNetworkConditions(); | |
networkConditions.IsOffline = true; | |
Dictionary<string, Object> parameters = new Dictionary<string, object>(); | |
parameters.Add("network_conditions", networkConditions); | |
customCommandDriver.ExecuteCustomDriverCommand(ChromeDriver.SetNetworkConditionsCommand, parameters); | |
try | |
{ | |
driver.Url = "https://www.saucedemo.com"; | |
Console.WriteLine("The navigation should have thrown an exception"); | |
} | |
catch (WebDriverException) | |
{ | |
customCommandDriver.ExecuteCustomDriverCommand(ChromeDriver.DeleteNetworkConditionsCommand, null); | |
} | |
driver.Url = "https://www.saucedemo.com"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment