예제 #1
0
        /// <summary>
        /// Executes the event.
        /// </summary>
        /// <param name="eventName">Name of the event to fire.</param>
        /// <param name="eventProperties"></param>
        /// <param name="WaitForEventToComplete"></param>
        private void ExecuteEvent(string eventName, NameValueCollection eventProperties, bool WaitForEventToComplete)
        {
            // See http://www.howtocreate.co.uk/tutorials/javascript/domevents
            // for more info about manually firing events

            var eventname = CleanupEventName(eventName);

            string command;

            if (eventname.Contains("mouse") || eventname == "click")
            {
                command = this.CreateMouseEventCommand(eventname);
            }
            else if (eventname.Contains("key"))
            {
                command = this.CreateKeyEventCommand(eventname, eventProperties);
            }
            else
            {
                command = this.CreateHTMLEventCommand(eventname);
            }


            command += "var res = " + this.ElementReference + ".dispatchEvent(event); if(res){true;}else{false;};";

            if (WaitForEventToComplete == false)
            {
                command = JSUtils.WrapCommandInTimer(command);
            }

            this.ClientPort.WriteAndReadAsBool(command);
        }