public void ShouldCreateDefaultSeleneseCommand()
 {
     string commandString = "open";
     string argument1 = "http://localhost";
     string argument2 = "";
     DefaultSeleneseCommand command = new DefaultSeleneseCommand(commandString, argument1, argument2);
     Assert.AreEqual("|" + commandString + "|" + argument1 + "|" + argument2 + "|", command.CommandString);
 }
 public void ShouldCreateDefaultSeleneseCommand()
 {
     string commandString = "open";
     string argument1 = "http://localhost";
     string argument2 = "";
     DefaultSeleneseCommand command = new DefaultSeleneseCommand(commandString, new string[]{argument1, argument2});
     Assert.AreEqual("cmd=open&1=http%3a%2f%2flocalhost&2=", command.CommandString);
 }
        public string DoCommand(string command, string argument1, string argument2)
        {
            ISeleneseCommand seleneseCommand = new DefaultSeleneseCommand(command, argument1, argument2);
            using (HttpWebResponse response = (HttpWebResponse) CreateWebRequest(seleneseCommand).GetResponse())
            {
                if (response.StatusCode != HttpStatusCode.OK)
                {
                    throw new SeleniumException(response.StatusDescription);
                }
                return ReadResponse(response);

            }
        }
        /// <summary>
        /// Send the specified Selenese command to the browser to be performed
        /// </summary>
        /// <param name="command">the Selenese command verb</param>
        /// <param name="args">the arguments to the Selenese command (depends on the verb)</param>
        /// <returns>the command result, defined by the Selenese JavaScript.  "getX" style
        ///		commands may return data from the browser</returns>
        public string DoCommand(string command, string[] args)
        {
            ISeleneseCommand seleneseCommand = new DefaultSeleneseCommand(command, args);
            using (HttpWebResponse response = (HttpWebResponse) CreateWebRequest(seleneseCommand).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;

            }
        }