public override void RunCommand(object sender)
        {
            object browserObject = null;

            var engine = (Core.Automation.Engine.AutomationEngineInstance)sender;

            var vInstance = v_InstanceName.ConvertToUserVariable(engine);

            browserObject = engine.GetAppInstance(vInstance);

            var browserInstance = (SHDocVw.InternetExplorer)browserObject;

            browserInstance.Navigate(v_URL.ConvertToUserVariable(sender));

            IEBrowserCreateCommand.WaitForReadyState(browserInstance);
        }
Пример #2
0
        private void RunCommandActions(IHTMLElement element, object sender, InternetExplorer browserInstance)
        {
            if (v_WebAction == "Fire onmousedown event")
            {
                ((IHTMLElement3)element).FireEvent("onmousedown");
            }
            else if (v_WebAction == "Fire onmouseover event")
            {
                ((IHTMLElement3)element).FireEvent("onmouseover");
            }
            else if (v_WebAction == "Invoke Click")
            {
                element.click();
                IEBrowserCreateCommand.WaitForReadyState(browserInstance);
            }
            else if ((v_WebAction == "Left Click") || (v_WebAction == "Middle Click") || (v_WebAction == "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());

                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());

                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 + System.Windows.Forms.SystemInformation.CaptionHeight) + userYAdjust).ToString(); // +90 accounts for title bar height
                newMouseMove.v_MouseClick     = v_WebAction;
                newMouseMove.RunCommand(sender);
            }
            else if (v_WebAction == "Set 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 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.ConvertToUserVariable(sender);

                element.setAttribute(attributeName, valueToSet);
            }
            else if (v_WebAction == "Set Text")
            {
                string attributeName = "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.ConvertToUserVariable(sender);

                element.setAttribute(attributeName, textToSet);
            }
            else if (v_WebAction == "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(sender, variableName);
            }
        }