예제 #1
0
        private void BuildElementClickActionCommand(string clickType)
        {
            BuildWaitForElementActionCommand();

            var clickElementActionCommand = new SeleniumElementActionCommand
            {
                v_InstanceName             = _browserInstanceName,
                v_SeleniumSearchParameters = SearchParameters,
                v_SeleniumElementAction    = clickType
            };

            _sequenceCommandList.Add(clickElementActionCommand);
        }
예제 #2
0
        private void BuildWaitForElementActionCommand()
        {
            var waitElementActionCommand = new SeleniumElementActionCommand
            {
                v_InstanceName             = _browserInstanceName,
                v_SeleniumSearchParameters = SearchParameters,
                v_SeleniumElementAction    = "Wait For Element To Exist"
            };

            DataTable webActionDT = waitElementActionCommand.v_WebActionParameterTable;
            DataRow   timeoutRow  = webActionDT.NewRow();

            timeoutRow["Parameter Name"]  = "Timeout (Seconds)";
            timeoutRow["Parameter Value"] = "30";
            webActionDT.Rows.Add(timeoutRow);

            _sequenceCommandList.Add(waitElementActionCommand);
        }
예제 #3
0
        private void BuildElementSetTextActionCommand(uint key)
        {
            bool toUpperCase = false;

            //determine if casing is needed
            if (GlobalHook.IsKeyDown(Keys.ShiftKey) && GlobalHook.IsKeyToggled(Keys.Capital))
            {
                toUpperCase = false;
            }
            else if (!GlobalHook.IsKeyDown(Keys.ShiftKey) && GlobalHook.IsKeyToggled(Keys.Capital))
            {
                toUpperCase = true;
            }
            else if (GlobalHook.IsKeyDown(Keys.ShiftKey) && !GlobalHook.IsKeyToggled(Keys.Capital))
            {
                toUpperCase = true;
            }
            else if (!GlobalHook.IsKeyDown(Keys.ShiftKey) && !GlobalHook.IsKeyToggled(Keys.Capital))
            {
                toUpperCase = false;
            }

            var buf           = new StringBuilder(256);
            var keyboardState = new byte[256];

            if (toUpperCase)
            {
                keyboardState[(int)Keys.ShiftKey] = 0xff;
            }

            GlobalHook.ToUnicode(key, 0, keyboardState, buf, 256, 0);
            string selectedKey = buf.ToString();

            //translate key press to sendkeys identifier
            if (((Keys)Enum.ToObject(typeof(Keys), key)).ToString() == GlobalHook.StopHookKey)
            {
                //STOP HOOK
                GlobalHook.StopHook();
                GlobalHook.HookStopped -= GlobalHook_HookStopped;
                return;
            }
            //check for a selenium compatible advanced key
            else if (_seleniumAdvancedKeyMap.TryGetValue(key, out string keyName))
            {
                selectedKey = $"[{keyName}]";
            }
            //return if key is neither character nor selenium compatible advanced key
            else if (selectedKey.Length > 1)
            {
                return;
            }

            //generate sendkeys together
            if ((_sequenceCommandList.Count > 1) && (_sequenceCommandList[_sequenceCommandList.Count - 1] is SeleniumElementActionCommand) &&
                (_sequenceCommandList[_sequenceCommandList.Count - 1] as SeleniumElementActionCommand).v_SeleniumElementAction == "Set Text")
            {
                var lastCreatedSendKeysCommand = (SeleniumElementActionCommand)_sequenceCommandList[_sequenceCommandList.Count - 1];

                //append chars to previously created command
                //this makes editing easier for the user because only 1 command is issued rather than multiples
                var previouslyInputChars = lastCreatedSendKeysCommand.v_WebActionParameterTable.Rows[0][1].ToString();
                lastCreatedSendKeysCommand.v_WebActionParameterTable.Rows[0][1] = previouslyInputChars + selectedKey;
            }
            else
            {
                BuildWaitForElementActionCommand();

                //build keyboard command
                var setTextElementActionCommand = new SeleniumElementActionCommand
                {
                    v_InstanceName             = _browserInstanceName,
                    v_SeleniumSearchParameters = SearchParameters,
                    v_SeleniumElementAction    = "Set Text"
                };

                DataTable webActionDT  = setTextElementActionCommand.v_WebActionParameterTable;
                DataRow   textToSetRow = webActionDT.NewRow();
                textToSetRow["Parameter Name"]  = "Text To Set";
                textToSetRow["Parameter Value"] = selectedKey;
                webActionDT.Rows.Add(textToSetRow);

                _sequenceCommandList.Add(setTextElementActionCommand);
            }
        }