public virtual void Submit() { Logger.LogAction("Submitting " + GetType().Name + " '" + ToString() + "'"); NativeElement.SubmitForm(); WaitForComplete(); }
/// <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(); } }
/// <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(); }
public virtual void Submit() { Logger.LogAction((LogFunction log) => { log("Submitting {0} '{1}', {2}", GetType().Name, IdOrName, Description); }); NativeElement.SubmitForm(); WaitForComplete(); }
/// <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); }
/// <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")); }
/// <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(); } }
/// <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(); }
public virtual void SetText(string text) { Do.Retry(() => { NativeElement.Clear(); NativeElement.SendKeys(text); }, RetryCount); }
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); }
/// <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()); }
/// <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)); }
/// <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(); }
/// <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); }
/// <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); }
/// <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(); } }
/// <summary> /// Try to get webElement /// </summary> public IWebElement TryGetElement(By by) { try { return(NativeElement.FindElement(by)); } catch (Exception) { return(null); } }
/// <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); } }
/// <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); }
/// <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); } }
/// <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); }
/// <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(); } }