Ejemplo n.º 1
0
 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);
     }
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
0
 /// <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));
 }
Ejemplo n.º 4
0
 public static bool HasClassWithValue(this BrowserElement element, string className)
 {
     return(element.Element.GetAttribute("class").Contains(className));
 }
Ejemplo n.º 5
0
 public static Size Size(this BrowserElement element)
 {
     return(element.Element.Size);
 }
Ejemplo n.º 6
0
 public static string Attribute(this BrowserElement element, string attribute)
 {
     return(element.Element.GetAttribute(attribute));
 }
Ejemplo n.º 7
0
 public static string Value(this BrowserElement element)
 {
     return(element.Element.GetAttribute("value"));
 }
Ejemplo n.º 8
0
 public static Point Location(this BrowserElement element)
 {
     return(element.Element.Location);
 }
Ejemplo n.º 9
0
 public static string Text(this BrowserElement element)
 {
     return(element.Element.Text);
 }
Ejemplo n.º 10
0
        public static void Click(this BrowserElement element)
        {
            var policy = Policy.Handle <ElementClickInterceptedException>().WaitAndRetry(5, x => TimeSpan.FromSeconds(1));

            policy.Execute(() => element.Element.Click());
        }
Ejemplo n.º 11
0
 public static void Type(this BrowserElement element, string text)
 {
     element.Element.SendKeys(text);
 }
Ejemplo n.º 12
0
        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;
            }
        }