示例#1
0
        public virtual void Submit()
        {
            Logger.LogAction("Submitting " + GetType().Name + " '" + ToString() + "'");

            NativeElement.SubmitForm();
            WaitForComplete();
        }
示例#2
0
        /// <summary>
        /// Sets the text value of the element.
        /// </summary>
        /// <param name="value"> The text to set the element to. </param>
        public Element SetText(string value)
        {
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value), "String parameter must not be null.");
            }

            if (!Enabled)
            {
                throw new InvalidOperationException("The element is not enabled.");
            }

            var pattern = NativeElement.GetCurrentPattern(UIA_PatternIds.UIA_ValuePatternId) as IUIAutomationValuePattern;

            if (pattern != null)
            {
                // Control supports the ValuePattern pattern so we can use the SetValue method to insert content.
                pattern.SetValue(value);
                return(this);
            }

            if (!KeyboardFocusable)
            {
                throw new NotKeyboardFocusableException("The element is read-only.");
            }

            // Set focus for input functionality and begin.
            NativeElement.SetFocus();

            // Pause before sending keyboard input.
            Thread.Sleep(100);
            Keyboard.TypeText(value);
            return(this);
        }
 /// <summary>
 /// Set text into webElement(field)
 /// </summary>
 public void SetText(string text)
 {
     Click();
     NativeElement.Clear();
     NativeElement.SendKeys(text);
     NativeElement.SendKeys(Keys.Enter);
 }
 /// <summary>
 /// Expand the drop-down list if it isn't opened
 /// </summary>
 public void Expand()
 {
     if (NativeElement.GetAttribute("aria-expanded") == "false")
     {
         Click();
     }
 }
示例#5
0
 /// <summary>
 /// Collapse the drop-down list if it's opened
 /// </summary>
 private void Collapse()
 {
     if (NativeElement.FindElement(By.XPath("./following-sibling::button")).GetAttribute("aria-expanded") == "true")
     {
         this.ClickOutsideControl();
     }
 }
        /// <summary>
        /// Set text into webElement(field) by javascript
        /// </summary>
        public void SetTextByJS(string text)
        {
            IJavaScriptExecutor jsExecutor = (IJavaScriptExecutor)DriverService.Driver;

            jsExecutor.ExecuteScript("arguments[0].value = '" + text + "';", NativeElement);
            NativeElement.Click();
        }
示例#7
0
        public virtual void Submit()
        {
            Logger.LogAction((LogFunction log) => { log("Submitting {0} '{1}', {2}", GetType().Name, IdOrName, Description); });

            NativeElement.SubmitForm();
            WaitForComplete();
        }
示例#8
0
 /// <summary>
 /// Execute click into text field and wait before setting the text
 /// </summary>
 public void SetTextWithWaiting(string text)
 {
     Click();
     Thread.Sleep(250);
     NativeElement.Clear();
     NativeElement.SendKeys(text);
 }
        /// <summary>
        /// Extracts 3-dimensional variable value. <seealso cref="HasVariable3d"/> <seealso cref="GetVariable1d"/>
        /// </summary>
        /// <param name="variable3d">variable to extract</param>
        /// <returns>array with 3 variable values in order X Y Z</returns>
        public double[] GetVariable3d(Variable3d variable3d)
        {
            IntPtr values = NativeElement.Element_GetVariable3d(_nativeInstance, variable3d.NativeVariable);

            double[] unmarshalledResults = Utils.Utils.UnmarshalNativeDoubles(values, 3);
            NativeUtilities.Utils_FreeDoubleArray(values);
            return(unmarshalledResults);
        }
示例#10
0
        /// <summary>
        /// Get the text of each chips
        /// </summary>
        public new List <string> GetText()
        {
            List <string> text = NativeElement
                                 .FindElements(By.XPath("./../../span/span"))
                                 .Select(el => el.Text.Trim()).ToList();

            return(text);
        }
 public virtual void Clear()
 {
     WaitFor.Condition(() =>
     {
         NativeElement.Clear();
         return(NativeElement.Text.Equals(string.Empty));
     }, $"Could not clear {ToString()}", RetryCount);
 }
 /// <summary>
 /// Get webElement text
 /// </summary>
 public override string GetText()
 {
     if (!string.IsNullOrEmpty(NativeElement.Text))
     {
         return(NativeElement.Text);
     }
     return(NativeElement.GetAttribute("value"));
 }
示例#13
0
 /// <summary>
 /// Expand the drop-down list if it isn't opened
 /// </summary>
 private void Expand()
 {
     if (NativeElement.FindElement(By.XPath("./following-sibling::button")).GetAttribute("aria-expanded") == "false")
     {
         ScrollTo();
         NativeElement.FindElement(By.XPath("./following-sibling::button")).Click();
     }
 }
示例#14
0
 /// <summary>
 /// Select the defined item from chips list by given chips name
 /// </summary>
 /// <param name="text">chips name</param>
 public void AddChipsFromDropDown(string text)
 {
     NativeElement.Click();
     SendKeys(text);
     DriverService.Driver
     .FindElement(By.XPath($"//ul[contains(@class, 'select')]/li[contains(text(), '{text}')]"))
     .Click();
 }
示例#15
0
 public virtual void SetText(string text)
 {
     Do.Retry(() =>
     {
         NativeElement.Clear();
         NativeElement.SendKeys(text);
     }, RetryCount);
 }
示例#16
0
文件: Element.cs 项目: csuffyy/FlaUI
        protected override object InternalGetPropertyValue(int propertyId, bool cached, bool useDefaultIfNotSupported)
        {
            var ignoreDefaultValue = useDefaultIfNotSupported ? 0 : 1;
            var returnValue        = cached ?
                                     NativeElement.GetCachedPropertyValueEx(propertyId, ignoreDefaultValue) :
                                     NativeElement.GetCurrentPropertyValueEx(propertyId, ignoreDefaultValue);

            return(returnValue);
        }
示例#17
0
        /// <returns>Array of <see cref="KratosNode"/> in this element</returns>
        public KratosNode[] GetNodes()
        {
            IntPtr pNodes = NativeElement.Element_Nodes(_nativeInstance);
            int    size   = 4; //TODO support for different element sizes

            IntPtr[] unmarshaled = new IntPtr[size];
            Marshal.Copy(pNodes, unmarshaled, 0, size);
            return(unmarshaled.Select(x => new KratosNode(x)).ToArray());
        }
示例#18
0
        /// <summary>
        /// Delete the first selected chips from input
        /// </summary>
        public void DeleteFirstChips()
        {
            var chipsFound = NativeElement.FindElements(
                LocatorTransformer.GetNativeLocators(
                    new FindByAttribute(Method.XPath, "../..//li[@title!='']"))).FirstOrDefault();

            new HtmlButton(chipsFound.FindElement(By.XPath(".//span"))).Click();
            NativeElement.Click();
        }
 public virtual void SetText(string text)
 {
     WaitFor.Condition(() =>
     {
         NativeElement.Clear();
         NativeElement.SendKeys(text);
         return(true);
     }, $"Could not set text on {ToString()}", TimeSpan.FromSeconds(15));
 }
示例#20
0
 /// <summary>
 /// Add new records as chips
 /// </summary>
 public void AddNewChips(params string[] chips)
 {
     foreach (var chip in chips)
     {
         SendKeys(chip);
         SendKeys(Keys.Enter);
     }
     NativeElement.ClickOutsideControl();
 }
示例#21
0
        /// <summary>
        /// Return all items names from chips list
        /// </summary>
        public List <string> GetAvailableValues()
        {
            NativeElement.Click();
            var elementList  = DriverService.Driver.FindElements(By.XPath("//li[contains(@id, '-result-')]"));
            var receivedList = elementList.Select(element => element.Text).ToList();

            NativeElement.Click();
            return(receivedList);
        }
示例#22
0
文件: Element.cs 项目: csuffyy/FlaUI
        /// <summary>
        /// Tries to get a clickable point of the element
        /// </summary>
        /// <param name="point">The clickable point or null, if no point was found</param>
        /// <returns>True if a point was found, false otherwise</returns>
        public bool TryGetClickablePoint(out Point point)
        {
            var tagPoint = new UIA.tagPOINT {
                x = 0, y = 0
            };
            var success = ComCallWrapper.Call(() => NativeElement.GetClickablePoint(out tagPoint)) != 0;

            point = success ? new Point(tagPoint.x, tagPoint.y) : null;
            return(success);
        }
示例#23
0
 /// <summary>
 /// Close the CMS drop-down
 /// </summary>
 public void Collapse()
 {
     if (NativeElement.GetAttribute("aria-expanded") == null)
     {
         return;
     }
     if (NativeElement.GetAttribute("aria-expanded").Equals("true"))
     {
         NativeElement.Click();
     }
 }
示例#24
0
 /// <summary>
 /// Try to get webElement
 /// </summary>
 public IWebElement TryGetElement(By by)
 {
     try
     {
         return(NativeElement.FindElement(by));
     }
     catch (Exception)
     {
         return(null);
     }
 }
示例#25
0
 /// <summary>
 /// Check if action drop-down is present
 /// </summary>
 private bool IsDropDownPresent()
 {
     try
     {
         return(NativeElement.FindElement(By.XPath("./following-sibling::button")).Displayed);
     }
     catch
     {
         return(false);
     }
 }
示例#26
0
 /// <summary>
 /// Try to get webElements
 /// </summary>
 public List <IWebElement> TryGetElements(By by)
 {
     try
     {
         return(NativeElement.FindElements(by).ToList());
     }
     catch (Exception)
     {
         return(null);
     }
 }
        public virtual void Set(string fileName)
        {
            var info = new FileInfo(fileName);

            if (!info.Exists)
            {
                throw new FileNotFoundException("File does not exist", fileName);
            }

            NativeElement.SetFileUploadFile(DomContainer.DialogWatcher, fileName);
        }
示例#28
0
 /// <summary>
 /// Check if the checkbox is checked at the moment
 /// </summary>
 public bool IsSelected()
 {
     try
     {
         NativeElement.GetAttribute("checked").Contains("checked");
         return(true);
     }
     catch
     {
         return(false);
     }
 }
示例#29
0
        /// <summary>
        /// Update the parent for the provided element.
        /// </summary>
        public Element UpdateParent()
        {
            var parent = NativeElement.GetCurrentParent();

            if (parent == null || parent.CurrentProcessId != NativeElement.CurrentProcessId)
            {
                return(this);
            }

            Parent = new Element(parent, Application, null);
            return(this);
        }
示例#30
0
 /// <summary>
 /// Open the CMS drop-down
 /// </summary>
 public void Expand()
 {
     if (NativeElement.GetAttribute("aria-expanded") == null)
     {
         NativeElement.Click();
         return;
     }
     if (NativeElement.GetAttribute("aria-expanded").Equals("false"))
     {
         NativeElement.Click();
     }
 }