Beispiel #1
0
        private void ClickActions(IClick Element, eElementAction ClickElementAction)
        {
            switch (ClickElementAction)
            {
            case eElementAction.Click:
                Element.Click();
                break;

            case eElementAction.JavaScriptClick:
                Element.JavascriptClick();
                break;

            case eElementAction.MouseClick:

                Element.MouseClick();
                break;

            case eElementAction.Select:
                Element.DoubleClick();
                break;

            case eElementAction.ClickAndValidate:

                string         ValidationType = (string)InputParams["ValidationType"];
                string         mClickType     = (string)InputParams["ClickType"];
                eElementAction ClickType      = (eElementAction)Enum.Parse(typeof(eElementAction), mClickType);

                ClickActions(Element, ClickType);
                IGingerWebElement ValidationElement = GetValidationElement();


                if ("IsVisible".Equals(ValidationType))
                {
                    if (ValidationElement.IsVisible())
                    {
                        ExecutionInfo = "Validation element is Visible";
                    }
                    else
                    {
                        Error = "Validation Element is not visble";
                    }
                }
                else if ("IsEnabled".Equals(ValidationType))
                {
                    if (ValidationElement.IsEnabled())
                    {
                        ExecutionInfo = "Validation element is Enabled";
                    }
                    else
                    {
                        Error = "Validation Element is not Enabled";
                    }
                }
                break;
            }
        }
        public void ExecuteAction(ref NodePlatformAction platformAction)
        {
            try
            {
                mPlatformAction = platformAction;

                InputParams = platformAction.InputParams;

                // convert the JArray to list of locators
                JObject Locators = (JObject)InputParams["Locators"];

                eElementType      ElementType = (eElementType)Enum.Parse(typeof(eElementType), (string)InputParams["ElementType"]);
                IGingerWebElement uiElement   = null;
                foreach (JProperty locator in Locators.Children())
                {
                    uiElement = LocateElement(ref ElementType, locator.Name, locator.Value.ToString());
                    if (uiElement != null)
                    {
                        platformAction.exInfo += "UI Element Located using: " + locator.Name + "=" + locator.Value;
                        break;
                    }
                }
                if (uiElement == null)
                {
                    platformAction.error += "Element not found";

                    return;
                }

                ElementAction = (eElementAction)Enum.Parse(typeof(eElementAction), (string)platformAction.InputParams["ElementAction"]);



                RunActionOnUIElement(uiElement, ElementType);

                //TODO: remove  // update output values - TODO: do it directlyon platformAction !!!
                foreach (NodeActionOutputValue nodeActionOutputValue in AOVs)
                {
                    platformAction.Output.Add(nodeActionOutputValue.Param, (string)nodeActionOutputValue.Value); // TODO: add path !!!
                }
            }

            catch (Exception Ex)
            {
                Error         = Ex.Message;
                ExecutionInfo = Ex.StackTrace;  // DO not put stacktrace !!!!
            }
        }
Beispiel #3
0
 private void HyperLinkActions(IGingerWebElement element, eElementAction mElementAction)
 {
     if (element is IHyperLink Hyperlink)
     {
         if (element is IClick ClickElement)
         {
             ClickActions(ClickElement, ElementAction);
         }
         else
         {
             switch (mElementAction)
             {
             case eElementAction.GetValue:
                 AOVs.Add(new NodeActionOutputValue()
                 {
                     Param = "Actual", Value = Hyperlink.GetValue()
                 });
                 break;
             }
         }
     }
 }
Beispiel #4
0
        public void ExecuteAction(ref NodePlatformAction platformAction)
        {
            try
            {
                mPlatformAction = platformAction;

                InputParams = platformAction.InputParams;

                // convert the JArray to list of locators
                JObject Locators = (JObject)InputParams["Locators"];

                eElementType      ElementType = (eElementType)Enum.Parse(typeof(eElementType), (string)InputParams["ElementType"]);
                IGingerWebElement uiElement   = null;
                JArray            Frames      = null;
                if (InputParams.ContainsKey("Frames"))
                {
                    Frames = (JArray)InputParams["Frames"];

                    if (Frames != null && Frames.Children().Count() > 0)
                    {
                        mPlatformService.BrowserActions.SwitchToDefaultContent();
                        foreach (JToken jf in Frames.Children())
                        {
                            IGingerWebElement GWA = mPlatformService.LocateWebElement.LocateElementByXPath(eElementType.WebElement, jf.ToString());
                            mPlatformService.BrowserActions.SwitchToFrame(GWA);
                        }
                    }
                }

                foreach (JProperty locator in Locators.Children())
                {
                    uiElement = WebPlatformActionHandler.LocateElement(ref ElementType, locator.Name, locator.Value.ToString(), mPlatformService);
                    if (uiElement != null)
                    {
                        platformAction.exInfo += "UI Element Located using: " + locator.Name + "=" + locator.Value;
                        break;
                    }
                }
                if (uiElement == null)
                {
                    platformAction.error += "Element not found";

                    return;
                }

                ElementAction = (eElementAction)Enum.Parse(typeof(eElementAction), (string)platformAction.InputParams["ElementAction"]);



                RunActionOnUIElement(uiElement, ElementType);

                //TODO: remove  // update output values - TODO: do it directlyon platformAction !!!
                foreach (NodeActionOutputValue nodeActionOutputValue in AOVs)
                {
                    platformAction.Output.Add(nodeActionOutputValue.Param, (string)nodeActionOutputValue.Value); // TODO: add path !!!
                }
            }

            catch (Exception Ex)
            {
                Error         = Ex.Message;
                ExecutionInfo = Ex.StackTrace;  // DO not put stacktrace !!!!
            }
        }
Beispiel #5
0
        private void PerformUIElementAction(GingerAction gingerAction, IWebElement e, eElementAction elementAction, string value)
        {
            switch (elementAction)
            {
            case eElementAction.Click:
                e.Click();
                break;

            case eElementAction.SetValue:

                //TODO: override in sub driver if needed
                e.Clear();
                e.SendKeys(value);
                break;

            case eElementAction.GetValue:
                gingerAction.Output.Add("Text", e.Text);
                break;

            default:
                gingerAction.AddError("PerformUIElementAction", "Unknown element action - " + elementAction);
                break;
            }
        }
Beispiel #6
0
        public void UIElementAction(GingerAction gingerAction, eElementType elementType, eLocateBy locateBy, string locateValue, eElementAction elementAction, string value = null)
        {
            Console.WriteLine("HandleUIElementAction");
            //First find the element
            IWebElement e = LocateElement(gingerAction, elementType, locateBy, locateValue);

            if (e == null)
            {
                Console.WriteLine("Element not found - " + elementType + " - " + locateBy + " " + locateValue);
                gingerAction.AddError("HandleUIElementAction", "Cannot find element: " + elementType + locateBy + " " + locateValue);
                return;
            }

            PerformUIElementAction(gingerAction, e, elementAction, value);
        }