コード例 #1
0
 private string GetPropertyName(eControlAction controlAction)
 {
     if (controlAction == eControlAction.GetState)
     {
         return(ActUIElement.eElementProperty.ToggleState.ToString());
     }
     else
     {
         return(string.Empty);
     }
 }
コード例 #2
0
        public void ExecuteAction(ref NodePlatformAction platformAction)
        {
            InputParams = platformAction.InputParams;



            string Value = (string)InputParams["Value"];
            List <NodeActionOutputValue> AOVs = new List <NodeActionOutputValue>();

            try
            {
                // use enum or string/const ???
                eControlAction ElementAction = (eControlAction)Enum.Parse(typeof(eControlAction), InputParams["ControlAction"].ToString());
                switch (ElementAction)
                {
                case eControlAction.GotoURL:
                    string GotoURLType = String.Empty;

                    if (InputParams.ContainsKey("GotoURLType"))
                    {
                        GotoURLType = (string)InputParams["GotoURLType"];
                    }
                    if (string.IsNullOrEmpty(GotoURLType))
                    {
                        GotoURLType = "Current";
                    }

                    BrowserService.Navigate(Value, GotoURLType);



                    platformAction.exInfo += "Navigated to: " + Value;

                    break;

                case eControlAction.GetPageURL:
                    platformAction.Output.Add("PageUrl", BrowserService.GetCurrentUrl());
                    break;

                case eControlAction.Maximize:
                    BrowserService.Maximize();
                    break;

                case eControlAction.Close:
                    BrowserService.CloseCurrentTab();
                    break;

                case eControlAction.CloseAll:
                    BrowserService.CloseWindow();
                    break;

                case eControlAction.Refresh:
                    BrowserService.Refresh();
                    break;

                case eControlAction.NavigateBack:
                    BrowserService.NavigateBack();
                    break;

                case eControlAction.DismissMessageBox:
                    BrowserService.DismissAlert();
                    break;

                case eControlAction.DeleteAllCookies:
                    BrowserService.DeleteAllCookies();
                    break;

                case eControlAction.AcceptMessageBox:

                    BrowserService.AcceptAlert();
                    break;

                case eControlAction.GetWindowTitle:

                    string Title = BrowserService.GetTitle();

                    AOVs.Add(new NodeActionOutputValue()
                    {
                        Param = "Actual", Value = Title
                    });
                    break;

                case eControlAction.GetMessageBoxText:

                    string AlertText = BrowserService.GetAlertText();
                    AOVs.Add(new NodeActionOutputValue()
                    {
                        Param = "Actual", Value = AlertText
                    });
                    break;

                case eControlAction.SetAlertBoxText:


                    string value = (string)InputParams["Value"];
                    BrowserService.SendAlertText(value);
                    break;

                case eControlAction.SwitchFrame:
                    string ElementLocateBy;
                    string Locatevalue;
                    string mElementType = "";
                    Locatevalue = (string)InputParams["LocateValue"];

                    object elb;
                    InputParams.TryGetValue("ElementLocateBy", out elb);

                    ElementLocateBy = elb != null?elb.ToString() : "";

                    if (string.IsNullOrEmpty(ElementLocateBy))
                    {
                        ElementLocateBy = (string)InputParams["LocateBy"];
                    }

                    if (string.IsNullOrEmpty(Locatevalue))
                    {
                        Locatevalue = (string)InputParams["Value"];
                    }


                    eElementType ElementType = eElementType.WebElement;
                    _ = Enum.TryParse <eElementType>(mElementType, out ElementType);
                    IGingerWebElement Element = LocateElement(ElementType, ElementLocateBy, Locatevalue);
                    BrowserService.SwitchToFrame(Element);
                    break;

                case eControlAction.RunJavaScript:
                    string javascript = (string)InputParams["javascript"];
                    object Output     = BrowserService.ExecuteScript(javascript);
                    if (Output != null)
                    {
                        platformAction.Output.Add("Actual", Output.ToString());
                    }
                    break;

                case eControlAction.GetPageSource:

                    string PageSource = BrowserService.GetPageSource();
                    AOVs.Add(new NodeActionOutputValue()
                    {
                        Param = "PageSource", Value = PageSource
                    });

                    break;

                case eControlAction.InjectJS:



                    break;
                }
            }
            catch (Exception ex)
            {
                platformAction.addError(ex.Message);
            }

            finally
            {
                platformAction.Output.OutputValues.AddRange(AOVs);
            }
        }
コード例 #3
0
        private ActUIElement.eElementAction GetElementActionType(eControlAction controlAction)
        {
            ActUIElement.eElementAction type;
            switch (controlAction)
            {
            case  eControlAction.SetValue:
                type = ActUIElement.eElementAction.SetValue;
                break;

            case eControlAction.GetValue:
                type = ActUIElement.eElementAction.GetValue;
                break;

            case eControlAction.Toggle:
                type = ActUIElement.eElementAction.Toggle;
                break;

            case eControlAction.Select:
                type = ActUIElement.eElementAction.Select;
                break;

            case eControlAction.AsyncSelect:
                type = ActUIElement.eElementAction.AsyncSelect;
                break;

            case eControlAction.Click:
                type = ActUIElement.eElementAction.Click;
                break;

            case eControlAction.AsyncClick:
                type = ActUIElement.eElementAction.AsyncClick;
                break;

            case eControlAction.WinClick:
                type = ActUIElement.eElementAction.WinClick;
                break;

            case eControlAction.winDoubleClick:
                type = ActUIElement.eElementAction.winDoubleClick;
                break;

            case eControlAction.MouseClick:
                type = ActUIElement.eElementAction.MouseClick;
                break;

            case eControlAction.MousePressRelease:
                type = ActUIElement.eElementAction.MousePressRelease;
                break;

            case eControlAction.IsVisible:
                type = ActUIElement.eElementAction.IsVisible;
                break;

            case eControlAction.IsMandatory:
                type = ActUIElement.eElementAction.IsMandatory;
                break;

            case eControlAction.IsEnabled:
                type = ActUIElement.eElementAction.IsEnabled;
                break;

            case eControlAction.GetName:
                type = ActUIElement.eElementAction.GetName;
                break;

            case eControlAction.AcceptDialog:
                type = ActUIElement.eElementAction.AcceptDialog;
                break;

            case eControlAction.DismissDialog:
                type = ActUIElement.eElementAction.DismissDialog;
                break;

            case eControlAction.ScrollUp:
                type = ActUIElement.eElementAction.ScrollUp;
                break;

            case eControlAction.ScrollDown:
                type = ActUIElement.eElementAction.ScrollDown;
                break;

            case eControlAction.ScrollLeft:
                type = ActUIElement.eElementAction.ScrollLeft;
                break;

            case eControlAction.ScrollRight:
                type = ActUIElement.eElementAction.ScrollRight;
                break;

            case eControlAction.SelectByIndex:
                type = ActUIElement.eElementAction.SelectByIndex;
                break;

            case eControlAction.GetValueByIndex:
                type = ActUIElement.eElementAction.GetValueByIndex;
                break;

            case eControlAction.GetItemCount:
                type = ActUIElement.eElementAction.GetItemCount;
                break;

            case eControlAction.SendKeys:
                type = ActUIElement.eElementAction.SetText;
                break;

            case eControlAction.SendKeyPressRelease:
                type = ActUIElement.eElementAction.SendKeyPressRelease;
                break;

            case eControlAction.DoubleClick:
                type = ActUIElement.eElementAction.DoubleClick;
                break;

            case eControlAction.SetFocus:
                type = ActUIElement.eElementAction.SetFocus;
                break;

            case eControlAction.GetState:
                type = ActUIElement.eElementAction.GetControlProperty;
                break;

            case eControlAction.GetDialogText:
                type = ActUIElement.eElementAction.GetDialogText;
                break;

            case eControlAction.Type:
                type = ActUIElement.eElementAction.SendKeys;
                break;

            case eControlAction.SelectDate:
                type = ActUIElement.eElementAction.SetDate;
                break;

            case eControlAction.IsChecked:
                type = ActUIElement.eElementAction.IsChecked;
                break;

            default:
                type = ActUIElement.eElementAction.Unknown;
                break;
            }
            return(type);
        }