Exemple #1
0
 /// <summary>
 /// Evaluates expression on global object.
 /// </summary>
 /// <param name="expression">Expression to evaluate.</param>
 /// <param name="objectGroup">(optional) Symbolic group name that can be used to release multiple objects.</param>
 /// <param name="returnByValue">(optional) Whether the result is expected to be a JSON object that should be sent by value.</param>
 /// <returns>result (RemoteObject): Evaluation result.
 /// wasThrown (optional boolean): True if the result was thrown during the evaluation.
 public static Command Evaluate(string expression, string objectGroup = null, bool returnByValue = false)
 {
     var com = new Command("Runtime.evaluate");
     com.addParam("expression", expression);
     com.addParam("objectGroup", objectGroup);
     if (returnByValue)
         com.addParam("returnByValue", returnByValue);
     return com;
 }
 /// <summary>
 /// Starts capturing instrumentation events.
 /// </summary>
 /// <param name="maxCallStackDepth">Samples JavaScript stack traces up to maxCallStackDepth, defaults to 5.</param>
 /// <returns></returns>
 public static Command Start(int? maxCallStackDepth = null)
 {
     var com = new Command("Timeline.start");
     if (maxCallStackDepth != null)
     {
         com.addParam("maxCallStackDepth", maxCallStackDepth);
     }
     return com;
 }
Exemple #3
0
 /// <summary>
 /// Returns properties of a given object. Object group of the result is inherited from the target object.
 /// </summary>
 /// <param name="objectId">Identifier of the object to return properties for.</param>
 /// <param name="ownProperties">If true, returns properties belonging only to the element itself, 
 /// not to its prototype chain.</param>
 /// <returns>result (array of PropertyDescriptor): Object properties.</returns>
 public static Command GetProperties(string objectId, bool ownProperties = false)
 {
     var com = new Command("Runtime.getProperties");
     com.addParam("objectId", objectId);
     if (ownProperties)
     {
         com.addParam("ownProperties", ownProperties);
     }
     return com;
 }
Exemple #4
0
 /// <summary>
 /// Reloads given page optionally ignoring the cache.
 /// </summary>
 /// <param name="ignoreCache">If true, browser cache is ignored (as if the user pressed Shift+refresh).</param>
 /// <param name="scriptToEvaluateOnLoad">If set, the script will be injected into all frames of the inspected page after reload.</param>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/page#command-reload"/>
 /// <returns></returns>
 public static Command Reload(bool ignoreCache = false, string scriptToEvaluateOnLoad = null)
 {
     var com = new Command("Page.reload");
     if (!ignoreCache)
     {
         com.addParam("ignoreCache", ignoreCache);
     }
     if (scriptToEvaluateOnLoad == null)
     {
         com.addParam("scriptToEvaluateOnLoad", scriptToEvaluateOnLoad);
     }
     return com;
 }
 /// <summary>
 /// Evaluates expression on a given call frame.
 /// </summary>
 /// <param name="callFrameId">Call frame identifier to evaluate on.</param>
 /// <param name="expression">Expression to evaluate.</param>
 /// <param name="objectGroup">(Optional) String object group name to put result into (allows rapid releasing resulting object handles using releaseObjectGroup).</param>
 /// <param name="returnByValue">(Optional) Whether the result is expected to be a JSON object that should be sent by value.</param>
 /// <returns>result (Runtime.RemoteObject): Object wrapper for the evaluation result.
 /// wasThrown (optional boolean): True if the result was thrown during the evaluation.</returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-evaluateOnCallFrame"/>
 public static Command EvaluateOnCallFrame(string callFrameId, string expression, string objectGroup = null, bool returnByValue = false)
 {
     var com = new Command("Debugger.evaluateOnCallFrame");
     com.addParam("callFrameId", callFrameId);
     com.addParam("expression", expression);
     if (objectGroup != null)
     {
         com.addParam("objectGroup", objectGroup);
     }
     if (returnByValue)
     {
         com.addParam("returnByValue", returnByValue);
     }
     return com;
 }
Exemple #6
0
 /// <summary>
 /// Calls function with given declaration on the given object. Object group of the result is inherited from the target object.
 /// </summary>
 /// <param name="objectId">Identifier of the object to call function on.</param>
 /// <param name="functionDeclaration">Declaration of the function to call.</param>
 /// <param name="arguments">(optional) Call arguments. All call arguments must belong to the same JavaScript world as the target object.</param>
 /// <param name="returnByValue">(optional) Whether the result is expected to be a JSON object which should be sent by value.</param>
 /// <returns>result (RemoteObject): Call result.
 /// wasThrown (optional boolean): True if the result was thrown during the evaluation.</returns>
 public static Command CallFunctionOn(string objectId, string functionDeclaration, CallArgument[] arguments = null, bool returnByValue = false)
 {
     var com = new Command("Runtime.callFunctionOn");
     com.addParam("objectId", objectId);
     com.addParam("functionDeclaration", functionDeclaration);
     if (arguments != null)
     {
         com.addParam("arguments", arguments);
     }
     if (returnByValue)
     {
         com.addParam("returnByValue", returnByValue);
     }
     return com;
 }
Exemple #7
0
        public async Task <Response> Send(Commands.Command command)
        {
            int id  = commandsSent;
            var mes = command.GetMessage(id);

            commandsSent++;
            bool hasResponse = false;

            if (socket.State != WebSocketState.Open)
            {
                if (socket.State == WebSocketState.None || socket.State == WebSocketState.Closed)
                {
                    socket.Open();
                    while (socket.State == WebSocketState.Connecting)
                    {
                        await Task.Delay(100);
                    }

                    if (socket.State != WebSocketState.Open)
                    {
                        throw new Exception("Socket could not be opened.");
                    }
                }
            }
            socket.Send(mes);
            while (!hasResponse)
            {
                await Task.Delay(10).ConfigureAwait(false);

                lock (responses)
                {
                    hasResponse = responses.ContainsKey(id);
                }
            }
            var response = responses[id];

            removeResponse(id);
            return(response);
        }
 /// <summary>
 /// Sets JavaScript breakpoint at given location specified either by URL or URL regex. 
 /// Once this command is issued, all existing parsed scripts will have breakpoints resolved and 
 /// returned in locations property. Further matching script parsing will result in subsequent 
 /// breakpointResolved events issued. This logical breakpoint will survive page reloads.
 /// </summary>
 /// <param name="lineNumber">Line number to set breakpoint at.</param>
 /// <param name="url">URL of the resources to set breakpoint on.</param>
 /// <param name="urlRegex">Regex pattern for the URLs of the resources to set breakpoints on. 
 /// Either url or urlRegex must be specified.</param>
 /// <param name="columnNumber">Offset in the line to set breakpoint at.</param>
 /// <param name="condition">Expression to use as a breakpoint condition. 
 /// When specified, debugger will only stop on the breakpoint if this expression evaluates to true.</param>
 /// <returns>breakpointId (string): Id of the created breakpoint for further reference.
 /// locations (optional array of Location): List of the locations this breakpoint resolved into upon addition.</returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-setBreakpointByUrl"/>
 public static Command SetBreakpointByUrl(
     int lineNumber,
     string url = null,
     string urlRegex = null,
     int? columnNumber = null,
     string condition = null)
 {
     if (url == null && urlRegex == null)
     {
         throw new ArgumentException("Either url or urlRegex must be specified.");
     }
     else
     {
         var com = new Command("Debugger.setBreakpointByUrl");
         com.addParam("lineNumber", lineNumber);
         if (url != null)
         {
             com.addParam("url", url);
         }
         if (urlRegex != null)
         {
             com.addParam("urlRegex", urlRegex);
         }
         if (columnNumber != null)
         {
             com.addParam("columnNumber", columnNumber);
         }
         if (condition != null)
         {
             com.addParam("condition", condition);
         }
         return com;
     }
 }
 /// <summary>
 /// Sets JavaScript breakpoint at a given location.
 /// </summary>
 /// <param name="location">Location to set breakpoint in.</param>
 /// <param name="condition">Expression to use as a breakpoint condition. When specified, 
 /// debugger will only stop on the breakpoint if this expression evaluates to true.</param>
 /// <returns>breakpointId (string): Id of the created breakpoint for further reference.
 /// actualLocation (Location): Location this breakpoint resolved into.</returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-setBreakpoint"/>
 public static Command SetBreakpoint(Location location, string condition = null)
 {
     var com = new Command("Debugger.setBreakpoint");
     com.addParam("location", location);
     if (condition != null)
     {
         com.addParam("condition", condition);
     }
     return com;
 }
Exemple #10
0
 /// <summary>
 /// Enables debugger for the given page. Clients should not assume that the debugging has been enabled until the result for this command is received.
 /// </summary>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-enable"/>
 public static Command Enable()
 {
     var com = new Command("Debugger.enable");
     return com;
 }
Exemple #11
0
 /// <summary>
 /// Continues execution until specific location is reached.
 /// </summary>
 /// <param name="location">Location to continue to.</param>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-continueToLocation"/>
 public static Command ContinueToLocation(Location location)
 {
     var com = new Command("Debugger.continueToLocation");
     com.addParam("location", location);
     return com;
 }
Exemple #12
0
 /// <summary>
 /// Tells whether setScriptSource is supported.
 /// </summary>
 /// <returns>result (boolean): True if setScriptSource is supported.</returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-canSetScriptSource"/>
 public static Command CanSetScriptSource()
 {
     var com = new Command("Debugger.canSetScriptSource");
     return com;
 }
Exemple #13
0
 /// <summary>
 /// Edits JavaScript source live.
 /// </summary>
 /// <param name="scriptId">Id of the script to edit.</param>
 /// <param name="scriptSource">New content of the script.</param>
 /// <returns>callFrames (optional array of CallFrame): New stack trace in case editing has happened while VM was stopped.</returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-setScriptSource"/>
 public static Command SetScriptSource(string scriptId, string scriptSource)
 {
     var com = new Command("Debugger.setScriptSource");
     com.addParam("scriptId", scriptId);
     com.addParam("scriptSource", scriptSource);
     return com;
 }
Exemple #14
0
 /// <summary>
 /// Navigates current page to the given URL.
 /// </summary>
 /// <param name="url">URL to navigate the page to.</param>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/page#command-navigate"/>
 /// <returns></returns>
 public static Command Navigate(string url)
 {
     var com = new Command("Page.navigate");
     com.addParam("url", url);
     return com;
 }
Exemple #15
0
 /// <summary>
 /// Enables page domain notifications.
 /// </summary>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/page#command-enable"/>
 /// <returns></returns>
 public static Command Enable()
 {
     var com = new Command("Page.enable");
     return com;
 }
Exemple #16
0
 /// <summary>
 /// Disables page domain notifications.
 /// </summary>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/page#command-disable"/>
 /// <returns></returns>
 public static Command Disable()
 {
     var com = new Command("Page.disable");
     return com;
 }
Exemple #17
0
 /// <summary>
 /// Releases all remote objects that belong to a given group.
 /// </summary>
 /// <param name="objectGroup">Symbolic object group name.</param>
 /// <returns></returns>
 public static Command ReleaseObjectGroup(string objectGroup)
 {
     var com = new Command("Runtime.releaseObjectGroup");
     com.addParam("objectGroup", objectGroup);
     return com;
 }
Exemple #18
0
 /// <summary>
 /// Releases remote object with given id.
 /// </summary>
 /// <param name="objectId">Identifier of the object to release.</param>
 /// <returns></returns>
 public static Command ReleaseObject(string objectId)
 {
     var com = new Command("Runtime.releaseObject");
     com.addParam("objectId", objectId);
     return com;
 }
Exemple #19
0
 /// <summary>
 /// Toggles ignoring cache for each request. If true, cache will not be used.
 /// </summary>
 /// <param name="cacheDisabled">Cache disabled state.</param>
 /// <returns></returns>
 public static Command SetCacheDisabled(bool cacheDisabled)
 {
     var com = new Command("Network.setCacheDisabled");
     com.addParam("cacheDisabled", cacheDisabled);
     return com;
 }
Exemple #20
0
 /// <summary>
 /// Activates / deactivates all breakpoints on the page.
 /// </summary>
 /// <param name="active">New value for breakpoints active state.</param>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-setBreakpointsActive"/>
 public static Command SetBreakpointsActive(bool active)
 {
     var com = new Command("Debugger.setBreakpointsActive");
     com.addParam("active", active);
     return com;
 }
Exemple #21
0
 /// <summary>
 /// Returns content served for the given request.
 /// </summary>
 /// <param name="requestId">Identifier of the network request to get content for.</param>
 /// <returns>body (string): Response body.
 /// base64Encoded (boolean): True, if content was sent as base64.</returns>
 public static Command GetResponseBody(string requestId)
 {
     var com = new Command("Network.getResponseBody");
     com.addParam("requestId", requestId);
     return com;
 }
Exemple #22
0
 /// <summary>
 /// Defines pause on exceptions state. Can be set to stop on all exceptions, uncaught exceptions or no exceptions. 
 /// Initial pause on exceptions state is none.
 /// </summary>
 /// <param name="state">Pause on exceptions mode.</param>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-setPauseOnExceptions"/>
 public static Command SetPauseOnExceptions(State state)
 {
     var com = new Command("Debugger.setPauseOnExceptions");
     com.addParam("state", Enum.GetName(typeof(State), state));
     return com;
 }
Exemple #23
0
 /// <summary>
 /// Enables network tracking, network events will now be delivered to the client.
 /// </summary>
 /// <returns></returns>
 public static Command Enable()
 {
     var com = new Command("Network.enable");
     return com;
 }
Exemple #24
0
 /// <summary>
 /// Steps into the function call.
 /// </summary>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-stepInto"/>
 public static Command StepInto()
 {
     var com = new Command("Debugger.stepInto");
     return com;
 }
Exemple #25
0
 /// <summary>
 /// Removes JavaScript breakpoint.
 /// </summary>
 /// <param name="breakPointId">breakpointId</param>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-removeBreakpoint"/>
 public static Command RemoveBreakpoint(string breakPointId)
 {
     var com = new Command("Debugger.removeBreakpoint");
     com.addParam("breakpointId", breakPointId);
     return com;
 }
Exemple #26
0
 /// <summary>
 /// Steps over the statement.
 /// </summary>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-stepOver"/>
 public static Command StepOver()
 {
     var com = new Command("Debugger.stepOver");
     return com;
 }
Exemple #27
0
 /// <summary>
 /// Resumes JavaScript execution.
 /// </summary>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-resume"/>
 public static Command Resume()
 {
     var com = new Command("Debugger.resume");
     return com;
 }
Exemple #28
0
 /// <summary>
 /// Disables debugger for given page.
 /// </summary>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-disable"/>
 public static Command Disable()
 {
     var com = new Command("Debugger.disable");
     return com;
 }
Exemple #29
0
 /// <summary>
 /// Searches for given string in script content.
 /// </summary>
 /// <param name="scriptId">Id of the script to search in.</param>
 /// <param name="query">String to search for.</param>
 /// <param name="caseSensitive">If true, search is case sensitive.</param>
 /// <param name="isRegex">If true, treats string parameter as regex.</param>
 /// <returns>result (array of Page.SearchMatch): List of search matches.</returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-searchInContent"/>
 public static Command SearchInContent(string scriptId, string query, bool caseSensitive = false, bool isRegex = false)
 {
     var com = new Command("Debugger.searchInContent");
     com.addParam("scriptId", scriptId);
     com.addParam("query", query);
     if (caseSensitive)
     {
         com.addParam("caseSensitive", caseSensitive);
     }
     if (isRegex)
     {
         com.addParam("isRegex", isRegex);
     }
     return com;
 }
Exemple #30
0
 /// <summary>
 /// Stops on the next JavaScript statement.
 /// </summary>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/debugger#command-pause"/>
 public static Command Pause()
 {
     var com = new Command("Debugger.pause");
     return com;
 }
Exemple #31
0
 /// <summary>
 /// Clears console messages collected in the browser.
 /// </summary>
 /// <returns></returns>
 /// <see cref="https://developers.google.com/chrome-developer-tools/docs/protocol/1.0/console#command-clearMessages"/>
 public static Command ClearMessages()
 {
     var com = new Command("Console.clearMessages");
     return com;
 }