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; } }
private void ExecuteSmartSyncAction(IWebPlatform webPlatformService, ref NodePlatformAction platformAction) { Dictionary <string, object> InputParams = platformAction.InputParams; int MaxTimeout = Int32.Parse(InputParams.ContainsKey("WaitTime") ? InputParams["WaitTime"].ToString() : (string.IsNullOrEmpty(InputParams["Value"].ToString()) ? "5" : InputParams["Value"].ToString())); string SmartSyncAction = InputParams["SmartSyncAction"] as string; string LocateValue = InputParams["LocateValue"] as string; string LocateBy = InputParams["LocateBy"] as string; eElementType ElementType = eElementType.WebElement; IGingerWebElement WebElement = null; Stopwatch st = new Stopwatch(); switch (SmartSyncAction) { case "WaitUntilDisplay": st.Reset(); st.Start(); WebElement = LocateElement(ref ElementType, LocateBy, LocateValue, webPlatformService); while (!(WebElement != null && (WebElement.IsVisible() || WebElement.IsEnabled()))) { Task.Delay(100); WebElement = LocateElement(ref ElementType, LocateBy, LocateValue, webPlatformService); if (st.ElapsedMilliseconds > MaxTimeout * 1000) { platformAction.addError("Smart Sync of WaitUntilDisplay is timeout"); break; } } break; case "WaitUntilDisapear": st.Reset(); st.Start(); WebElement = LocateElement(ref ElementType, LocateBy, LocateValue, webPlatformService); if (WebElement == null) { return; } else { st.Start(); while (WebElement != null && WebElement.IsVisible()) { Task.Delay(100); WebElement = LocateElement(ref ElementType, LocateBy, LocateValue, webPlatformService); if (st.ElapsedMilliseconds > MaxTimeout * 1000) { platformAction.addError("Smart Sync of WaitUntilDisapear is timeout"); break; } } } break; default: platformAction.error = "Smart Sync " + SmartSyncAction + "Action Not found"; break; } }
/// <summary> /// Perform Common action on GngerWebelement return true if iction is perfomed /// </summary> /// <param name="Element"></param> /// <returns></returns> private bool PerformCommonActions(IGingerWebElement Element) { bool performed = true; switch (ElementAction) { case eElementAction.DragDrop: IGingerWebElement TargetElement = null; Element.DragAndDrop("", TargetElement); break; case eElementAction.GetAttrValue: Element.GetAttribute(""); break; case eElementAction.GetHeight: AOVs.Add(new NodeActionOutputValue() { Param = "Height", Value = Element.GetHeight() }); break; case eElementAction.GetItemCount: throw new NotImplementedException("Get Item count is not implementd"); case eElementAction.GetSize: Size s = Element.GetSize(); AOVs.Add(new NodeActionOutputValue() { Param = "Height", Value = s.Height }); AOVs.Add(new NodeActionOutputValue() { Param = "Width", Value = s.Width }); break; case eElementAction.GetStyle: AOVs.Add(new NodeActionOutputValue() { Param = "Style", Value = Element.GetStyle() }); break; case eElementAction.GetWidth: AOVs.Add(new NodeActionOutputValue() { Param = "Width", Value = Element.GetWidth() }); break; case eElementAction.Hover: Element.Hover(); break; case eElementAction.IsEnabled: AOVs.Add(new NodeActionOutputValue() { Param = "Enabled", Value = Element.IsEnabled() }); break; case eElementAction.IsVisible: AOVs.Add(new NodeActionOutputValue() { Param = "Visible", Value = Element.IsVisible() }); break; case eElementAction.MouseRightClick: Element.RightClick(); break; case eElementAction.RunJavaScript: Element.RunJavascript(""); break; case eElementAction.SetFocus: Element.SetFocus(); break; default: performed = false; break; } return(performed); }