private void DriverDevTools() { devTools = WebDriver as IDevTools; session = devTools.GetDevToolsSession(); devToolsSession = session.GetVersionSpecificDomains <DevToolsSessionDomains>(); devToolsSession.Network.Enable(new Network.EnableCommandSettings()); }
public void Setup() { driver = EnvironmentManager.Instance.GetCurrentDriver(); devTools = driver as IDevTools; if (devTools == null) { Assert.Ignore("{0} does not support Chrome DevTools Protocol", EnvironmentManager.Instance.Browser); return; } session = devTools.GetDevToolsSession(); }
/// <summary> /// Initializes a new instance of the <see cref="RemoteJavaScriptEngine"/> class. /// </summary> /// <param name="driver">The <see cref="IWebDriver"/> instance in which the JavaScript engine is executing.</param> public RemoteJavaScriptEngine(IWebDriver driver) { this.session = new Lazy <DevToolsSession>(() => { IDevTools devToolsDriver = driver as IDevTools; if (session == null) { throw new WebDriverException("Driver must implement IDevTools to use these features"); } return(devToolsDriver.GetDevToolsSession()); }); }
public void SetAddionalHeaders() { IDevTools devTools = _driver as IDevTools; DevToolsSession session = devTools.GetDevToolsSession(); var extraHeader = new Network.Headers(); extraHeader.Add("headerName", "executeHacked"); session.SendCommand(new Network.SetExtraHTTPHeadersCommandSettings() { Headers = extraHeader }); _driver.Url = "https://www.executeautomation.com"; }
/// <summary> /// Initializes a new instance of the <see cref="RemoteNetwork"/> class. /// </summary> /// <param name="driver">The <see cref="IWebDriver"/> instance on which the network should be monitored.</param> public RemoteNetwork(IWebDriver driver) { // Use of Lazy<T> means this exception won't be thrown until the user first // attempts to access the DevTools session, probably on the first call to // StartMonitoring(). this.session = new Lazy <DevToolsSession>(() => { IDevTools devToolsDriver = driver as IDevTools; if (session == null) { throw new WebDriverException("Driver must implement IDevTools to use these features"); } return(devToolsDriver.GetDevToolsSession()); }); }
public void Setup() { new DriverManager().SetUpDriver(new ChromeConfig()); ChromeOptions chromeOptions = new ChromeOptions(); chromeOptions.AddArguments("--headless"); //Set ChromeDriver driver = new ChromeDriver(); //Get DevTools IDevTools devTools = driver as IDevTools; //DevTools Session session = devTools.GetDevToolsSession(); devToolsSession = session.GetVersionSpecificDomains <DevToolsSessionDomains>(); devToolsSession.Network.Enable(new Network.EnableCommandSettings()); }
/// <summary> /// Initializes a new instance of the <see cref="JavaScriptEngine"/> class. /// </summary> /// <param name="driver">The <see cref="IWebDriver"/> instance in which the JavaScript engine is executing.</param> public JavaScriptEngine(IWebDriver driver) { // Use of Lazy<T> means this exception won't be thrown until the user first // attempts to access the DevTools session, probably on the first call to // StartEventMonitoring() or in adding scripts to the instance. this.driver = driver; this.session = new Lazy <DevToolsSession>(() => { IDevTools devToolsDriver = driver as IDevTools; if (devToolsDriver == null) { throw new WebDriverException("Driver must implement IDevTools to use these features"); } return(devToolsDriver.GetDevToolsSession()); }); }
static void Main(string[] args) { var driver = new ChromeDriver(); IDevTools devTool = driver; var session = devTool.GetDevToolsSession(); var domains = session.GetVersionSpecificDomains <DevToolsSessionDomains>(); domains.Page.Enable(new EnableCommandSettings()); domains.Page.AddScriptToEvaluateOnNewDocument(new AddScriptToEvaluateOnNewDocumentCommandSettings() { Source = "Object.defineProperty(navigator, 'webdriver', { get: () => undefined });" + @"Object.defineProperty(navigator, 'platform', { get: () => 'MacOS'}); " + "" }); driver.Navigate().GoToUrl("https://selenium.dev"); driver.Quit(); }
public async Task NetworkIntercerptAsync() { _driver.Navigate().GoToUrl("http://www.google.com?gl=us"); IDevTools devTools = _driver as IDevTools; DevToolsSession session = devTools.GetDevToolsSession(); await session.SendCommand(new EnableCommandSettings()); var metricsResponse = await session.SendCommand <GetMetricsCommandSettings, GetMetricsCommandResponse>( new GetMetricsCommandSettings()); _driver.Navigate().GoToUrl("http://www.google.com"); _driver.Quit(); var metrics = metricsResponse.Metrics; foreach (Metric metric in metrics) { Console.WriteLine("{0} = {1}", metric.Name, metric.Value); } }