public void ShouldCreateDefaultRemoteCommand() { string commandString = "open"; string argument1 = "http://localhost"; string argument2 = ""; DefaultRemoteCommand command = new DefaultRemoteCommand(commandString, new string[]{argument1, argument2}); Assert.AreEqual("cmd=open&1=http%3a%2f%2flocalhost&2=", command.CommandString); }
/// <summary> /// Send the specified remote command to the browser to be performed /// </summary> /// <param name="command">the remote command verb</param> /// <param name="args">the arguments to the remote command (depends on the verb)</param> /// <returns>the command result, defined by the remote JavaScript. "getX" style /// commands may return data from the browser</returns> public string DoCommand(string command, string[] args) { IRemoteCommand remoteCommand = new DefaultRemoteCommand(command, args); using (HttpWebResponse response = (HttpWebResponse)CreateWebRequest(remoteCommand).GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { throw new SeleniumException(response.StatusDescription); } string resultBody = ReadResponse(response); if (!resultBody.StartsWith("OK")) { throw new SeleniumException(resultBody); } return(resultBody); } }
/// <summary> /// Send the specified remote command to the browser to be performed /// </summary> /// <param name="command">the remote command verb</param> /// <param name="args">the arguments to the remote command (depends on the verb)</param> /// <returns>the command result, defined by the remote JavaScript. "getX" style /// commands may return data from the browser</returns> public string DoCommand(string command, string[] args) { IRemoteCommand remoteCommand = new DefaultRemoteCommand(command, args); using (HttpWebResponse response = (HttpWebResponse) CreateWebRequest(remoteCommand).GetResponse()) { if (response.StatusCode != HttpStatusCode.OK) { throw new SeleniumException(response.StatusDescription); } string resultBody = ReadResponse(response); if (!resultBody.StartsWith("OK")) { throw new SeleniumException(resultBody); } return resultBody; } }