public static BrowserElement GetChildWithText(this BrowserElement element, string text) { try { var bySelector = By.XPath($"//*[text()='{text}']"); return(element.Element.FindElements(bySelector).Select(el => new BrowserElement() { Element = el, Selector = bySelector }).First()); } catch (Exception) { return(null); } }
public static BrowserElement Get(this BrowserElement element, Locator selector) { try { var childElement = element.Element.FindElement(selector.ElementLocator); return(new BrowserElement() { Element = childElement, Selector = selector.ElementLocator }); } catch (Exception) { return(null); } }
/// <summary> /// The passed elements will be later returned to the remote event, including the current value of the DOM (HTML) Element. /// </summary> /// <param name="element"></param> /// <param name="returnType"></param> public void AddReturnObject(BrowserElement element, string hiddenValue = "", ReturnType returnType = ReturnType.Text) { this.ReturnObjects.Add(new BrowserRemoteReturnObject(element.Id, hiddenValue, element.Type, returnType)); }
public static bool HasClassWithValue(this BrowserElement element, string className) { return(element.Element.GetAttribute("class").Contains(className)); }
public static Size Size(this BrowserElement element) { return(element.Element.Size); }
public static string Attribute(this BrowserElement element, string attribute) { return(element.Element.GetAttribute(attribute)); }
public static string Value(this BrowserElement element) { return(element.Element.GetAttribute("value")); }
public static Point Location(this BrowserElement element) { return(element.Element.Location); }
public static string Text(this BrowserElement element) { return(element.Element.Text); }
public static void Click(this BrowserElement element) { var policy = Policy.Handle <ElementClickInterceptedException>().WaitAndRetry(5, x => TimeSpan.FromSeconds(1)); policy.Execute(() => element.Element.Click()); }
public static void Type(this BrowserElement element, string text) { element.Element.SendKeys(text); }
public void AddElement(BrowserElement element) { element.OrderIndex = AddedElements++; //element.Position = this.Position; switch (element.Type) { case BrowserElementType.BrowserBoxSelection: BrowserBoxSelection boxSelection = element as BrowserBoxSelection; break; case BrowserElementType.Button: BrowserButton button = element as BrowserButton; Buttons.Add(button); break; case BrowserElementType.Title: BrowserTitle title = element as BrowserTitle; Titles.Add(title); break; case BrowserElementType.Text: BrowserText text = element as BrowserText; Texts.Add(text); break; case BrowserElementType.TextBox: BrowserTextBox textBox = element as BrowserTextBox; TextBoxes.Add(textBox); break; case BrowserElementType.Card: BrowserCard card = element as BrowserCard; Cards.Add(card); break; case BrowserElementType.Password: BrowserPasswordTextBox passwordTextBox = element as BrowserPasswordTextBox; PasswordTextBoxes.Add(passwordTextBox); break; //case BrowserElementType.YesNoDialog: // BrowserYesNoDialog yesNoDialog = element as BrowserYesNoDialog; // YesNoDialog = yesNoDialog; // break; case BrowserElementType.Checkbox: BrowserCheckBox checkBox = element as BrowserCheckBox; CheckBoxes.Add(checkBox); break; case BrowserElementType.DropDown: BrowserDropDown dropDown = element as BrowserDropDown; DropDowns.Add(dropDown); break; case BrowserElementType.ProgressBar: BrowserProgressBar progressBar = element as BrowserProgressBar; ProgressBars.Add(progressBar); break; case BrowserElementType.Container: BrowserContainer container = element as BrowserContainer; Container.Add(container); break; case BrowserElementType.Icon: BrowserButtonIcon icon = element as BrowserButtonIcon; Icons.Add(icon); break; default: NAPI.Util.ConsoleOutput($"UNKNOWN ELEMENT OF TYPE {element.Type}"); break; } }