public override void RunCommand(object sender)
        {
            var engine = (AutomationEngineInstance)sender;
            //create variable window name
            var variableWindowName = v_WindowName.ConvertUserVariableToString(engine);

            if (variableWindowName == "Current Window")
            {
                variableWindowName = User32Functions.GetActiveWindowTitle();
            }

            dynamic requiredHandle = null;

            if (v_AutomationType != "Wait For Element To Exist")
            {
                requiredHandle = SearchForGUIElement(sender, variableWindowName);
            }

            switch (v_AutomationType)
            {
            //determine element click type
            case "Click Element":
                //if handle was not found
                if (requiredHandle == null)
                {
                    throw new Exception("Element was not found in window '" + variableWindowName + "'");
                }
                //create search params
                var clickType = (from rw in v_UIAActionParameters.AsEnumerable()
                                 where rw.Field <string>("Parameter Name") == "Click Type"
                                 select rw.Field <string>("Parameter Value")).FirstOrDefault();

                //get x adjust
                var xAdjust = (from rw in v_UIAActionParameters.AsEnumerable()
                               where rw.Field <string>("Parameter Name") == "X Adjustment"
                               select rw.Field <string>("Parameter Value")).FirstOrDefault();

                //get y adjust
                var yAdjust = (from rw in v_UIAActionParameters.AsEnumerable()
                               where rw.Field <string>("Parameter Name") == "Y Adjustment"
                               select rw.Field <string>("Parameter Value")).FirstOrDefault();

                //convert potential variable
                var xAdjustVariable = xAdjust.ConvertUserVariableToString(engine);
                var yAdjustVariable = yAdjust.ConvertUserVariableToString(engine);

                //parse to int
                var xAdjustInt = int.Parse(xAdjustVariable);
                var yAdjustInt = int.Parse(yAdjustVariable);

                //get clickable point
                var newPoint = requiredHandle.GetClickablePoint();

                //send mousemove command
                var newMouseMove = new SendMouseMoveCommand
                {
                    v_XMousePosition = (newPoint.X + xAdjustInt).ToString(),
                    v_YMousePosition = (newPoint.Y + yAdjustInt).ToString(),
                    v_MouseClick     = clickType
                };

                //run commands
                newMouseMove.RunCommand(sender);
                break;

            case "Set Text":
                string textToSet = (from rw in v_UIAActionParameters.AsEnumerable()
                                    where rw.Field <string>("Parameter Name") == "Text To Set"
                                    select rw.Field <string>("Parameter Value")).FirstOrDefault();


                string clearElement = (from rw in v_UIAActionParameters.AsEnumerable()
                                       where rw.Field <string>("Parameter Name") == "Clear Element Before Setting Text"
                                       select rw.Field <string>("Parameter Value")).FirstOrDefault();

                string encryptedData = (from rw in v_UIAActionParameters.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Encrypted Text"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault();
                if (clearElement == null)
                {
                    clearElement = "No";
                }
                if (encryptedData == "Encrypted")
                {
                    textToSet = EncryptionServices.DecryptString(textToSet, "TASKT");
                }
                textToSet = textToSet.ConvertUserVariableToString(engine);

                if (requiredHandle.Current.IsEnabled && requiredHandle.Current.IsKeyboardFocusable)
                {
                    object valuePattern = null;
                    if (!requiredHandle.TryGetCurrentPattern(ValuePattern.Pattern, out valuePattern))
                    {
                        //The control does not support ValuePattern Using keyboard input

                        // Set focus for input functionality and begin.
                        requiredHandle.SetFocus();

                        // Pause before sending keyboard input.
                        Thread.Sleep(100);

                        if (clearElement.ToLower() == "yes")
                        {
                            // Delete existing content in the control and insert new content.
                            SendKeys.SendWait("^{HOME}");       // Move to start of control
                            SendKeys.SendWait("^+{END}");       // Select everything
                            SendKeys.SendWait("{DEL}");         // Delete selection
                        }
                        SendKeys.SendWait(textToSet);
                    }
                    else
                    {
                        if (clearElement.ToLower() == "no")
                        {
                            string currentText;
                            object tPattern = null;
                            if (requiredHandle.TryGetCurrentPattern(TextPattern.Pattern, out tPattern))
                            {
                                var textPattern = (TextPattern)tPattern;
                                currentText = textPattern.DocumentRange.GetText(-1).TrimEnd('\r').ToString();     // often there is an extra '\r' hanging off the end.
                            }
                            else
                            {
                                currentText = requiredHandle.Current.Name.ToString();
                            }
                            textToSet = currentText + textToSet;
                        }
                        requiredHandle.SetFocus();
                        ((ValuePattern)valuePattern).SetValue(textToSet);
                    }
                }
                break;

            case "Set Secure Text":
                string secureString = (from rw in v_UIAActionParameters.AsEnumerable()
                                       where rw.Field <string>("Parameter Name") == "Secure String Variable"
                                       select rw.Field <string>("Parameter Value")).FirstOrDefault();

                string _clearElement = (from rw in v_UIAActionParameters.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Clear Element Before Setting Text"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault();

                var secureStrVariable = secureString.ConvertUserVariableToObject(engine);

                if (secureStrVariable is SecureString)
                {
                    secureString = ((SecureString)secureStrVariable).ConvertSecureStringToString();
                }
                else
                {
                    throw new ArgumentException("Provided Argument is not a 'Secure String'");
                }

                if (_clearElement == null)
                {
                    _clearElement = "No";
                }

                if (requiredHandle.Current.IsEnabled && requiredHandle.Current.IsKeyboardFocusable)
                {
                    object valuePattern = null;
                    if (!requiredHandle.TryGetCurrentPattern(ValuePattern.Pattern, out valuePattern))
                    {
                        //The control does not support ValuePattern Using keyboard input

                        // Set focus for input functionality and begin.
                        requiredHandle.SetFocus();

                        // Pause before sending keyboard input.
                        Thread.Sleep(100);

                        if (_clearElement.ToLower() == "yes")
                        {
                            // Delete existing content in the control and insert new content.
                            SendKeys.SendWait("^{HOME}");       // Move to start of control
                            SendKeys.SendWait("^+{END}");       // Select everything
                            SendKeys.SendWait("{DEL}");         // Delete selection
                        }
                        SendKeys.SendWait(secureString);
                    }
                    else
                    {
                        if (_clearElement.ToLower() == "no")
                        {
                            string currentText;
                            object tPattern = null;
                            if (requiredHandle.TryGetCurrentPattern(TextPattern.Pattern, out tPattern))
                            {
                                var textPattern = (TextPattern)tPattern;
                                currentText = textPattern.DocumentRange.GetText(-1).TrimEnd('\r').ToString();     // often there is an extra '\r' hanging off the end.
                            }
                            else
                            {
                                currentText = requiredHandle.Current.Name.ToString();
                            }
                            secureString = currentText + secureString;
                        }
                        requiredHandle.SetFocus();
                        ((ValuePattern)valuePattern).SetValue(secureString);
                    }
                }
                break;

            case "Clear Element":
                if (requiredHandle.Current.IsEnabled && requiredHandle.Current.IsKeyboardFocusable)
                {
                    object valuePattern = null;
                    if (!requiredHandle.TryGetCurrentPattern(ValuePattern.Pattern, out valuePattern))
                    {
                        //The control does not support ValuePattern Using keyboard input

                        // Set focus for input functionality and begin.
                        requiredHandle.SetFocus();

                        // Pause before sending keyboard input.
                        Thread.Sleep(100);

                        // Delete existing content in the control and insert new content.
                        SendKeys.SendWait("^{HOME}");       // Move to start of control
                        SendKeys.SendWait("^+{END}");       // Select everything
                        SendKeys.SendWait("{DEL}");         // Delete selection
                    }
                    else
                    {
                        requiredHandle.SetFocus();
                        ((ValuePattern)valuePattern).SetValue("");
                    }
                }
                break;

            case "Get Text":
            //if element exists type
            case "Check If Element Exists":
                //apply to variable
                var applyToVariable = (from rw in v_UIAActionParameters.AsEnumerable()
                                       where rw.Field <string>("Parameter Name") == "Apply To Variable"
                                       select rw.Field <string>("Parameter Value")).FirstOrDefault();

                //declare search result
                string searchResult = "";
                if (v_AutomationType == "Get Text")
                {
                    //string currentText;
                    object tPattern = null;
                    if (requiredHandle.TryGetCurrentPattern(TextPattern.Pattern, out tPattern))
                    {
                        var textPattern = (TextPattern)tPattern;
                        searchResult = textPattern.DocumentRange.GetText(-1).TrimEnd('\r').ToString();     // often there is an extra '\r' hanging off the end.
                    }
                    else
                    {
                        searchResult = requiredHandle.Current.Name.ToString();
                    }
                }

                else if (v_AutomationType == "Check If Element Exists")
                {
                    //determine search result
                    if (requiredHandle == null)
                    {
                        searchResult = "False";
                    }
                    else
                    {
                        searchResult = "True";
                    }
                }
                //store data
                searchResult.StoreInUserVariable(engine, applyToVariable);
                break;

            case "Wait For Element To Exist":
                var timeoutText = (from rw in v_UIAActionParameters.AsEnumerable()
                                   where rw.Field <string>("Parameter Name") == "Timeout (Seconds)"
                                   select rw.Field <string>("Parameter Value")).FirstOrDefault();

                timeoutText = timeoutText.ConvertUserVariableToString(engine);

                int timeOut = Convert.ToInt32(timeoutText);

                var timeToEnd = DateTime.Now.AddSeconds(timeOut);
                while (timeToEnd >= DateTime.Now)
                {
                    try
                    {
                        requiredHandle = SearchForGUIElement(sender, variableWindowName);
                        break;
                    }
                    catch (Exception)
                    {
                        engine.ReportProgress("Element Not Yet Found... " + (timeToEnd - DateTime.Now).Seconds + "s remain");
                        Thread.Sleep(1000);
                    }
                }
                break;

            case "Get Value From Element":
                if (requiredHandle == null)
                {
                    throw new Exception("Element was not found in window '" + variableWindowName + "'");
                }
                //get value from property
                var propertyName = (from rw in v_UIAActionParameters.AsEnumerable()
                                    where rw.Field <string>("Parameter Name") == "Get Value From"
                                    select rw.Field <string>("Parameter Value")).FirstOrDefault();

                //apply to variable
                var applyToVariable2 = (from rw in v_UIAActionParameters.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Apply To Variable"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault();

                //get required value
                var requiredValue = requiredHandle.Current.GetType().GetRuntimeProperty(propertyName)?.GetValue(requiredHandle.Current).ToString();

                //store into variable
                ((object)requiredValue).StoreInUserVariable(engine, applyToVariable2);
                break;

            default:
                throw new NotImplementedException("Automation type '" + v_AutomationType + "' not supported.");
            }
        }
        private void RunCommandActions(IHTMLElement element, object sender, InternetExplorer browserInstance)
        {
            var engine = (AutomationEngineInstance)sender;

            switch (v_WebAction)
            {
            case "Fire onmousedown event":
                ((IHTMLElement3)element).FireEvent("onmousedown");
                break;

            case "Fire onmouseover event":
                ((IHTMLElement3)element).FireEvent("onmouseover");
                break;

            case "Invoke Click":
                element.click();
                IECreateBrowserCommand.WaitForReadyState(browserInstance);
                break;

            case "Left Click":
            case "Middle Click":
            case "Right Click":
                int elementXposition = FindElementXPosition(element);
                int elementYposition = FindElementYPosition(element);

                //inputs need to be validated

                int userXAdjust = Convert.ToInt32((from rw in v_WebActionParameterTable.AsEnumerable()
                                                   where rw.Field <string>("Parameter Name") == "X Adjustment"
                                                   select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));

                int userYAdjust = Convert.ToInt32((from rw in v_WebActionParameterTable.AsEnumerable()
                                                   where rw.Field <string>("Parameter Name") == "Y Adjustment"
                                                   select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));

                var ieClientLocation = User32Functions.GetWindowPosition(new IntPtr(browserInstance.HWND));

                SendMouseMoveCommand newMouseMove = new SendMouseMoveCommand();

                newMouseMove.v_XMousePosition = ((elementXposition + ieClientLocation.left + 10) + userXAdjust).ToString();                                  // + 10 gives extra padding
                newMouseMove.v_YMousePosition = ((elementYposition + ieClientLocation.top + 90 + SystemInformation.CaptionHeight) + userYAdjust).ToString(); // +90 accounts for title bar height
                newMouseMove.v_MouseClick     = v_WebAction;
                newMouseMove.RunCommand(sender);
                break;

            case "Set Attribute":
                string setAttributeName = (from rw in v_WebActionParameterTable.AsEnumerable()
                                           where rw.Field <string>("Parameter Name") == "Attribute Name"
                                           select rw.Field <string>("Parameter Value")).FirstOrDefault();

                string valueToSet = (from rw in v_WebActionParameterTable.AsEnumerable()
                                     where rw.Field <string>("Parameter Name") == "Value To Set"
                                     select rw.Field <string>("Parameter Value")).FirstOrDefault();

                valueToSet = valueToSet.ConvertUserVariableToString(engine);

                element.setAttribute(setAttributeName, valueToSet);
                break;

            case "Set Text":
                string setTextAttributeName = "value";

                string textToSet = (from rw in v_WebActionParameterTable.AsEnumerable()
                                    where rw.Field <string>("Parameter Name") == "Text To Set"
                                    select rw.Field <string>("Parameter Value")).FirstOrDefault();

                textToSet = textToSet.ConvertUserVariableToString(engine);

                element.setAttribute(setTextAttributeName, textToSet);
                break;

            case "Get Attribute":
                string attributeName = (from rw in v_WebActionParameterTable.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Attribute Name"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault();

                string variableName = (from rw in v_WebActionParameterTable.AsEnumerable()
                                       where rw.Field <string>("Parameter Name") == "Variable Name"
                                       select rw.Field <string>("Parameter Value")).FirstOrDefault();

                string convertedAttribute = Convert.ToString(element.getAttribute(attributeName));

                convertedAttribute.StoreInUserVariable(engine, variableName);
                break;
            }
        }
Example #3
0
        public override void RunCommand(object sender)
        {
            var  engine   = (AutomationEngineInstance)sender;
            bool testMode = TestMode;
            //user image to bitmap
            Bitmap userImage = new Bitmap(Common.Base64ToImage(v_ImageCapture));
            double accuracy;

            try
            {
                accuracy = double.Parse(v_MatchAccuracy.ConvertUserVariableToString(engine));
                if (accuracy > 1 || accuracy < 0)
                {
                    throw new ArgumentOutOfRangeException("Accuracy value is out of range (0-1)");
                }
            }
            catch (Exception)
            {
                throw new InvalidDataException("Accuracy value is invalid");
            }

            if (testMode)
            {
                FindImageElement(userImage, accuracy);
                return;
            }

            dynamic element = null;

            if (v_ImageAction == "Wait For Image To Exist")
            {
                var timeoutText = (from rw in v_ImageActionParameterTable.AsEnumerable()
                                   where rw.Field <string>("Parameter Name") == "Timeout (Seconds)"
                                   select rw.Field <string>("Parameter Value")).FirstOrDefault();

                timeoutText = timeoutText.ConvertUserVariableToString(engine);
                int timeOut   = Convert.ToInt32(timeoutText);
                var timeToEnd = DateTime.Now.AddSeconds(timeOut);

                while (timeToEnd >= DateTime.Now)
                {
                    try
                    {
                        element = FindImageElement(userImage, accuracy);

                        if (element == null)
                        {
                            throw new Exception("Image Element Not Found");
                        }
                        else
                        {
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        engine.ReportProgress("Element Not Yet Found... " + (timeToEnd - DateTime.Now).Seconds + "s remain");
                        Thread.Sleep(1000);
                    }
                }

                if (element == null)
                {
                    throw new Exception("Image Element Not Found");
                }

                return;
            }
            else
            {
                element = FindImageElement(userImage, accuracy);
            }

            try
            {
                string clickPosition;
                int    xAdjust;
                int    yAdjust;
                switch (v_ImageAction)
                {
                case "Click Image":
                    string clickType = (from rw in v_ImageActionParameterTable.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Click Type"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault();
                    clickPosition = (from rw in v_ImageActionParameterTable.AsEnumerable()
                                     where rw.Field <string>("Parameter Name") == "Click Position"
                                     select rw.Field <string>("Parameter Value")).FirstOrDefault();
                    xAdjust = Convert.ToInt32((from rw in v_ImageActionParameterTable.AsEnumerable()
                                               where rw.Field <string>("Parameter Name") == "X Adjustment"
                                               select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));
                    yAdjust = Convert.ToInt32((from rw in v_ImageActionParameterTable.AsEnumerable()
                                               where rw.Field <string>("Parameter Name") == "Y Adjustment"
                                               select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));

                    Point clickPositionPoint = GetClickPosition(clickPosition, element);

                    //move mouse to position
                    var mouseMove = new SendMouseMoveCommand
                    {
                        v_XMousePosition = (clickPositionPoint.X + xAdjust).ToString(),
                        v_YMousePosition = (clickPositionPoint.Y + yAdjust).ToString(),
                        v_MouseClick     = clickType
                    };

                    mouseMove.RunCommand(sender);
                    break;

                case "Set Text":
                    string textToSet = (from rw in v_ImageActionParameterTable.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Text To Set"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine);
                    clickPosition = (from rw in v_ImageActionParameterTable.AsEnumerable()
                                     where rw.Field <string>("Parameter Name") == "Click Position"
                                     select rw.Field <string>("Parameter Value")).FirstOrDefault();
                    xAdjust = Convert.ToInt32((from rw in v_ImageActionParameterTable.AsEnumerable()
                                               where rw.Field <string>("Parameter Name") == "X Adjustment"
                                               select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));
                    yAdjust = Convert.ToInt32((from rw in v_ImageActionParameterTable.AsEnumerable()
                                               where rw.Field <string>("Parameter Name") == "Y Adjustment"
                                               select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));
                    string encryptedData = (from rw in v_ImageActionParameterTable.AsEnumerable()
                                            where rw.Field <string>("Parameter Name") == "Encrypted Text"
                                            select rw.Field <string>("Parameter Value")).FirstOrDefault();

                    if (encryptedData == "Encrypted")
                    {
                        textToSet = EncryptionServices.DecryptString(textToSet, "TASKT");
                    }

                    Point setTextPositionPoint = GetClickPosition(clickPosition, element);

                    //move mouse to position and set text
                    var setTextMouseMove = new SendMouseMoveCommand
                    {
                        v_XMousePosition = (setTextPositionPoint.X + xAdjust).ToString(),
                        v_YMousePosition = (setTextPositionPoint.Y + yAdjust).ToString(),
                        v_MouseClick     = "Left Click"
                    };
                    setTextMouseMove.RunCommand(sender);

                    var simulator = new InputSimulator();
                    simulator.Keyboard.TextEntry(textToSet);
                    Thread.Sleep(100);
                    break;

                case "Set Secure Text":
                    var secureString = (from rw in v_ImageActionParameterTable.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Secure String Variable"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault();
                    clickPosition = (from rw in v_ImageActionParameterTable.AsEnumerable()
                                     where rw.Field <string>("Parameter Name") == "Click Position"
                                     select rw.Field <string>("Parameter Value")).FirstOrDefault();
                    xAdjust = Convert.ToInt32((from rw in v_ImageActionParameterTable.AsEnumerable()
                                               where rw.Field <string>("Parameter Name") == "X Adjustment"
                                               select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));
                    yAdjust = Convert.ToInt32((from rw in v_ImageActionParameterTable.AsEnumerable()
                                               where rw.Field <string>("Parameter Name") == "Y Adjustment"
                                               select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));

                    var secureStrVariable = secureString.ConvertUserVariableToObject(engine);

                    if (secureStrVariable is SecureString)
                    {
                        secureString = ((SecureString)secureStrVariable).ConvertSecureStringToString();
                    }
                    else
                    {
                        throw new ArgumentException("Provided Argument is not a 'Secure String'");
                    }

                    Point setSecureTextPositionPoint = GetClickPosition(clickPosition, element);

                    //move mouse to position and set text
                    var setSecureTextMouseMove = new SendMouseMoveCommand
                    {
                        v_XMousePosition = (setSecureTextPositionPoint.X + xAdjust).ToString(),
                        v_YMousePosition = (setSecureTextPositionPoint.Y + yAdjust).ToString(),
                        v_MouseClick     = "Left Click"
                    };
                    setSecureTextMouseMove.RunCommand(sender);

                    var simulator2 = new InputSimulator();
                    simulator2.Keyboard.TextEntry(secureString);
                    Thread.Sleep(100);
                    break;

                case "Check If Image Exists":
                    var outputVariable = (from rw in v_ImageActionParameterTable.AsEnumerable()
                                          where rw.Field <string>("Parameter Name") == "Output Bool Variable Name"
                                          select rw.Field <string>("Parameter Value")).FirstOrDefault();

                    //remove brackets from variable
                    outputVariable = outputVariable.Replace("{", "").Replace("}", "");

                    if (element != null)
                    {
                        "True".StoreInUserVariable(engine, outputVariable);
                    }
                    else
                    {
                        "False".StoreInUserVariable(engine, outputVariable);
                    }
                    break;

                default:
                    break;
                }
                CommandControls.ShowAllForms();
            }
            catch (Exception ex)
            {
                CommandControls.ShowAllForms();
                if (element == null)
                {
                    throw new Exception("Specified image was not found in window!");
                }
                else
                {
                    throw ex;
                }
            }
        }
Example #4
0
        public override void RunCommand(object sender)
        {
            var engine = (AutomationEngineInstance)sender;
            //convert to user variable -- https://github.com/saucepleez/taskt/issues/66
            var     seleniumSearchParam = v_SeleniumSearchParameter.ConvertUserVariableToString(engine);
            var     browserObject       = v_InstanceName.GetAppInstance(engine);
            var     seleniumInstance    = (IWebDriver)browserObject;
            dynamic element             = null;

            if (v_SeleniumElementAction == "Wait For Element To Exist")
            {
                var timeoutText = (from rw in v_WebActionParameterTable.AsEnumerable()
                                   where rw.Field <string>("Parameter Name") == "Timeout (Seconds)"
                                   select rw.Field <string>("Parameter Value")).FirstOrDefault();

                timeoutText = timeoutText.ConvertUserVariableToString(engine);
                int timeOut   = Convert.ToInt32(timeoutText);
                var timeToEnd = DateTime.Now.AddSeconds(timeOut);

                while (timeToEnd >= DateTime.Now)
                {
                    try
                    {
                        element = FindElement(seleniumInstance, seleniumSearchParam);
                        break;
                    }
                    catch (Exception)
                    {
                        engine.ReportProgress("Element Not Yet Found... " + (timeToEnd - DateTime.Now).Seconds + "s remain");
                        Thread.Sleep(1000);
                    }
                }

                if (element == null)
                {
                    throw new Exception("Element Not Found");
                }

                return;
            }
            else if (seleniumSearchParam != string.Empty)
            {
                element = FindElement(seleniumInstance, seleniumSearchParam);
            }

            switch (v_SeleniumElementAction)
            {
            case "Invoke Click":
                int seleniumWindowHeightY = seleniumInstance.Manage().Window.Size.Height;
                int elementPositionY      = element.Location.Y;
                if (elementPositionY > seleniumWindowHeightY)
                {
                    String scroll          = String.Format("window.scroll(0, {0})", elementPositionY);
                    IJavaScriptExecutor js = browserObject as IJavaScriptExecutor;
                    js.ExecuteScript(scroll);
                }
                element.Click();
                break;

            case "Left Click":
            case "Right Click":
            case "Middle Click":
            case "Double Left Click":
                int userXAdjust = Convert.ToInt32((from rw in v_WebActionParameterTable.AsEnumerable()
                                                   where rw.Field <string>("Parameter Name") == "X Adjustment"
                                                   select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));

                int userYAdjust = Convert.ToInt32((from rw in v_WebActionParameterTable.AsEnumerable()
                                                   where rw.Field <string>("Parameter Name") == "Y Adjustment"
                                                   select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine));

                var elementLocation = element.Location;
                SendMouseMoveCommand newMouseMove = new SendMouseMoveCommand();
                var seleniumWindowPosition        = seleniumInstance.Manage().Window.Position;
                newMouseMove.v_XMousePosition = (seleniumWindowPosition.X + elementLocation.X + 30 + userXAdjust).ToString();     // added 30 for offset
                newMouseMove.v_YMousePosition = (seleniumWindowPosition.Y + elementLocation.Y + 130 + userYAdjust).ToString();    //added 130 for offset
                newMouseMove.v_MouseClick     = v_SeleniumElementAction;
                newMouseMove.RunCommand(sender);
                break;

            case "Set Text":
                string textToSet = (from rw in v_WebActionParameterTable.AsEnumerable()
                                    where rw.Field <string>("Parameter Name") == "Text To Set"
                                    select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine);


                string clearElement = (from rw in v_WebActionParameterTable.AsEnumerable()
                                       where rw.Field <string>("Parameter Name") == "Clear Element Before Setting Text"
                                       select rw.Field <string>("Parameter Value")).FirstOrDefault();

                string encryptedData = (from rw in v_WebActionParameterTable.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Encrypted Text"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault();

                if (clearElement == null)
                {
                    clearElement = "No";
                }

                if (clearElement.ToLower() == "yes")
                {
                    element.Clear();
                }

                if (encryptedData == "Encrypted")
                {
                    textToSet = EncryptionServices.DecryptString(textToSet, "TASKT");
                }

                string[] potentialKeyPresses = textToSet.Split('{', '}');

                Type        seleniumKeys = typeof(OpenQA.Selenium.Keys);
                FieldInfo[] fields       = seleniumKeys.GetFields(BindingFlags.Static | BindingFlags.Public);

                //check if chunked string contains a key press command like {ENTER}
                foreach (string chunkedString in potentialKeyPresses)
                {
                    if (chunkedString == "")
                    {
                        continue;
                    }

                    if (fields.Any(f => f.Name == chunkedString))
                    {
                        string keyPress = (string)fields.Where(f => f.Name == chunkedString).FirstOrDefault().GetValue(null);
                        element.SendKeys(keyPress);
                    }
                    else
                    {
                        //convert to user variable - https://github.com/saucepleez/taskt/issues/22
                        var convertedChunk = chunkedString.ConvertUserVariableToString(engine);
                        element.SendKeys(convertedChunk);
                    }
                }
                break;

            case "Set Secure Text":
                var secureString = (from rw in v_WebActionParameterTable.AsEnumerable()
                                    where rw.Field <string>("Parameter Name") == "Secure String Variable"
                                    select rw.Field <string>("Parameter Value")).FirstOrDefault();

                string _clearElement = (from rw in v_WebActionParameterTable.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Clear Element Before Setting Text"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault();

                var secureStrVariable = secureString.ConvertUserVariableToObject(engine);

                if (secureStrVariable is SecureString)
                {
                    secureString = ((SecureString)secureStrVariable).ConvertSecureStringToString();
                }
                else
                {
                    throw new ArgumentException("Provided Argument is not a 'Secure String'");
                }

                if (_clearElement == null)
                {
                    _clearElement = "No";
                }

                if (_clearElement.ToLower() == "yes")
                {
                    element.Clear();
                }

                string[] _potentialKeyPresses = secureString.Split('{', '}');

                Type        _seleniumKeys = typeof(OpenQA.Selenium.Keys);
                FieldInfo[] _fields       = _seleniumKeys.GetFields(BindingFlags.Static | BindingFlags.Public);

                //check if chunked string contains a key press command like {ENTER}
                foreach (string chunkedString in _potentialKeyPresses)
                {
                    if (chunkedString == "")
                    {
                        continue;
                    }

                    if (_fields.Any(f => f.Name == chunkedString))
                    {
                        string keyPress = (string)_fields.Where(f => f.Name == chunkedString).FirstOrDefault().GetValue(null);
                        element.SendKeys(keyPress);
                    }
                    else
                    {
                        //convert to user variable - https://github.com/saucepleez/taskt/issues/22
                        var convertedChunk = chunkedString.ConvertUserVariableToString(engine);
                        element.SendKeys(convertedChunk);
                    }
                }
                break;

            case "Get Options":
                string applyToVarName = (from rw in v_WebActionParameterTable.AsEnumerable()
                                         where rw.Field <string>("Parameter Name") == "Variable Name"
                                         select rw.Field <string>("Parameter Value")).FirstOrDefault();


                string attribName = (from rw in v_WebActionParameterTable.AsEnumerable()
                                     where rw.Field <string>("Parameter Name") == "Attribute Name"
                                     select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine);

                var optionsItems = new List <string>();
                var ele          = (IWebElement)element;
                var select       = new SelectElement(ele);
                var options      = select.Options;

                foreach (var option in options)
                {
                    var optionValue = option.GetAttribute(attribName);
                    optionsItems.Add(optionValue);
                }

                optionsItems.StoreInUserVariable(engine, applyToVarName);

                break;

            case "Select Option":
                string selectionType = (from rw in v_WebActionParameterTable.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Selection Type"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault();

                string selectionParam = (from rw in v_WebActionParameterTable.AsEnumerable()
                                         where rw.Field <string>("Parameter Name") == "Selection Parameter"
                                         select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine);

                seleniumInstance.SwitchTo().ActiveElement();

                var el = (IWebElement)element;
                var selectionElement = new SelectElement(el);

                switch (selectionType)
                {
                case "Select By Index":
                    selectionElement.SelectByIndex(int.Parse(selectionParam));
                    break;

                case "Select By Text":
                    selectionElement.SelectByText(selectionParam);
                    break;

                case "Select By Value":
                    selectionElement.SelectByValue(selectionParam);
                    break;

                case "Deselect By Index":
                    selectionElement.DeselectByIndex(int.Parse(selectionParam));
                    break;

                case "Deselect By Text":
                    selectionElement.DeselectByText(selectionParam);
                    break;

                case "Deselect By Value":
                    selectionElement.DeselectByValue(selectionParam);
                    break;

                case "Deselect All":
                    selectionElement.DeselectAll();
                    break;

                default:
                    throw new NotImplementedException();
                }
                break;

            case "Get Text":
            case "Get Attribute":
            case "Get Count":
                string VariableName = (from rw in v_WebActionParameterTable.AsEnumerable()
                                       where rw.Field <string>("Parameter Name") == "Variable Name"
                                       select rw.Field <string>("Parameter Value")).FirstOrDefault();

                string attributeName = (from rw in v_WebActionParameterTable.AsEnumerable()
                                        where rw.Field <string>("Parameter Name") == "Attribute Name"
                                        select rw.Field <string>("Parameter Value")).FirstOrDefault().ConvertUserVariableToString(engine);

                string elementValue;
                if (v_SeleniumElementAction == "Get Text")
                {
                    elementValue = element.Text;
                }
                else if (v_SeleniumElementAction == "Get Count")
                {
                    elementValue = "1";
                    if (element is ReadOnlyCollection <IWebElement> )
                    {
                        elementValue = ((ReadOnlyCollection <IWebElement>)element).Count().ToString();
                    }
                }
                else
                {
                    elementValue = element.GetAttribute(attributeName);
                }

                elementValue.StoreInUserVariable(engine, VariableName);
                break;

            case "Get Matching Element(s)":
                var variableName = (from rw in v_WebActionParameterTable.AsEnumerable()
                                    where rw.Field <string>("Parameter Name") == "Variable Name"
                                    select rw.Field <string>("Parameter Value")).FirstOrDefault();

                if (!(element is IWebElement))
                {
                    //create element list
                    List <IWebElement> elementList = new List <IWebElement>();
                    foreach (IWebElement item in element)
                    {
                        elementList.Add(item);
                    }
                    elementList.StoreInUserVariable(engine, variableName);
                }
                else
                {
                    ((IWebElement)element).StoreInUserVariable(engine, variableName);
                }
                break;

            case "Get Table":
                var DTVariableName = (from rw in v_WebActionParameterTable.AsEnumerable()
                                      where rw.Field <string>("Parameter Name") == "Variable Name"
                                      select rw.Field <string>("Parameter Value")).FirstOrDefault();

                // Get HTML (Source) of the Element
                string       tableHTML = element.GetAttribute("innerHTML").ToString();
                HtmlDocument doc       = new HtmlDocument();

                //Load Source (String) as HTML Document
                doc.LoadHtml(tableHTML);

                //Get Header Tags
                var       headers = doc.DocumentNode.SelectNodes("//tr/th");
                DataTable DT      = new DataTable();

                //If headers found
                if (headers != null && headers.Count != 0)
                {
                    // add columns from th (headers)
                    foreach (HtmlNode header in headers)
                    {
                        DT.Columns.Add(Regex.Replace(header.InnerText, @"\t|\n|\r", "").Trim());
                    }
                }
                else
                {
                    var columnsCount = doc.DocumentNode.SelectSingleNode("//tr[1]").ChildNodes.Where(node => node.Name == "td").Count();
                    DT.Columns.AddRange((Enumerable.Range(1, columnsCount).Select(dc => new DataColumn())).ToArray());
                }

                // select rows with td elements and load each row (containing <td> tags) into DataTable
                foreach (var row in doc.DocumentNode.SelectNodes("//tr[td]"))
                {
                    DT.Rows.Add(row.SelectNodes("td").Select(td => Regex.Replace(td.InnerText, @"\t|\n|\r", "").Trim()).ToArray());
                }

                DT.StoreInUserVariable(engine, DTVariableName);
                break;

            case "Clear Element":
                element.Clear();
                break;

            case "Switch to Frame":
                if (seleniumSearchParam == "")
                {
                    seleniumInstance.SwitchTo().DefaultContent();
                }
                else
                {
                    seleniumInstance.SwitchTo().Frame(element);
                }
                break;

            default:
                throw new Exception("Element Action was not found");
            }
        }