Class UiElement

java.lang.Object
com.workfusion.rpa.helpers.UiElement
All Implemented Interfaces:
com.workfusion.rpa.internal.api.element.WebElement, org.openqa.selenium.interactions.Locatable, org.openqa.selenium.SearchContext, org.openqa.selenium.TakesScreenshot, org.openqa.selenium.WebElement, org.openqa.selenium.WrapsElement

public class UiElement extends Object implements com.workfusion.rpa.internal.api.element.WebElement, org.openqa.selenium.WrapsElement, org.openqa.selenium.interactions.Locatable
This class wraps object of WebElement and provides new functionality.
Samples
$("#errorMessage").shouldBe(visible, enabled).click();
$("td").parent().doubleClick();
$(".edit").pressBackSpace();

Driver model

This class does not talk to a browser directly. It operates on the RPA Driver, which is a façade over one of the real automation backends:

  • Web — a Selenium 4 based driver automating a browser;
  • Desktop — a driver automating a native desktop application's UI (not a browser);
  • Universal — supports both web and desktop targets.

Although the API surface reuses Selenium types (such as By and Coordinates), a given call may ultimately be carried out by the desktop driver rather than by a browser. Each method below is tagged with a Driver Type listing the backend(s) that support it; invoking a method on an unsupported backend throws IllegalStateException (e.g. setText(Object) is Desktop-only, innerHtml() is Web-only). Methods with no tag work on any backend.

Coordinates and offsets

All mouse methods that accept an (offsetX, offsetY) pair (for example click(int, int), doubleClick(int, int), contextClick(int, int)) measure the offset from the TOP-LEFT corner of the element's bounding rectangle, in pixels:

  • offsetX grows to the right;
  • offsetY grows downward;
  • (0, 0) is the top-left corner of the element itself.

This is intentionally different from the Selenium 4 Actions convention, where click(element, x, y) measures offsets from the element's center. To keep the simpler top-left-based addressing, these methods convert the top-left offset into the center-relative offset Selenium 4 expects (subtracting centerX()/centerY()) before delegating to Actions. See recalculateOffsetToCenter(int, int).

The helpers left(), top(), right(), bottom(), centerX() and centerY() return element-local coordinates (relative to the top-left corner) and can be passed straight back in as offsets, e.g. element.click(element.centerX(), element.centerY()) clicks the element's center.

Coordinate samples
$("[CLASS:Edit]").click(5, 5); — click 5px right and 5px down from the element's top-left corner.
$("[CLASS:Edit]").click(left(), top()); — click the top-left corner itself (left() and top() are both 0).
UiElement btn = $("[CLASS:Button]"); btn.click(btn.centerX(), btn.centerY()); — click the element's center; equivalent to a plain btn.click() but explicit about the target point.
$("[CLASS:Edit]").doubleClick(0, bottom()); — double-click the bottom-left corner (bottom() is the element height).
  • Method Summary

    Modifier and Type
    Method
    Description
    $(String cssSelector)
    Driver Type: Desktop, Web
    $(String cssSelector, int index)
    Driver Type: Desktop, Web
    $(org.openqa.selenium.By selector)
    Driver Type: Desktop, Web
    $(org.openqa.selenium.By selector, int index)
    Driver Type: Desktop, Web
    $$(String cssSelector)
    Driver Type: Desktop, Web
    $$(org.openqa.selenium.By selector)
    Driver Type: Desktop, Web
    append(Object text)
    Append given text to the text field.
    attr(String attributeName)
    Get the attribute of the element.
    int
    Bottom edge of the element in element-local coordinates (relative to its top-left corner).
    int
    Horizontal center of the element relative to its top-left corner.
    int
    Vertical center of the element relative to its top-left corner.
    void
    Clears the text of this input or textarea element.
    void
    Click the element
    click(int clicks)
    Click the element number of times
    click(int offsetX, int offsetY)
    Left-click the element at a point offset from its TOP-LEFT corner.
    click(int clicks, int offsetX, int offsetY)
    Left-click the element a given number of times at a point offset from its TOP-LEFT corner.
    closest(String tagOrClass)
    Find closes ancestor element matching given criteria.
    Click with right mouse button on this element
    contextClick(int offsetX, int offsetY)
    Right-click (context-click) the element at a point offset from its TOP-LEFT corner.
    Copies selected text
    Double click the element
    doubleClick(int offsetX, int offsetY)
    Double-click the element at a point offset from its TOP-LEFT corner.
    boolean
    Two UiElements are equal when they are of the same class and wrap equal underlying elements.
    find(String cssSelector)
    Find the first matching element inside given element
    find(String cssSelector, int index)
    Find the Nth matching element inside given element
    find(org.openqa.selenium.By selector)
    Find the first matching element inside given element
    find(org.openqa.selenium.By selector, int index)
    Find the Nth matching element inside given element
    findAll(String cssSelector)
    Short form of webDriver.findElements(thisElement, By.cssSelector(cssSelector))
    findAll(org.openqa.selenium.By selector)
    Short form of webDriver.findElements(thisElement, selector)
    com.workfusion.rpa.internal.api.element.WebElement
    findElement(org.openqa.selenium.By by)
    Finds the first descendant element matching the given criteria.
    List<org.openqa.selenium.WebElement>
    findElements(org.openqa.selenium.By by)
    Finds all descendant elements matching the given criteria.
    boolean
    Sets input focus on this element.
     
     
    Gets the value of the given attribute.
    org.openqa.selenium.interactions.Coordinates
    Returns the Coordinates of this element, used by mouse interactions to address it.
    Gets the value of a CSS property of this element.
    Gets the value of the given attribute as declared in the DOM markup, without any property normalization.
    Gets the value of the given DOM property (the current, possibly script-updated value), as opposed to the static markup attribute.
     
    org.openqa.selenium.Point
     
    org.openqa.selenium.Rectangle
     
    <X> X
    getScreenshotAs(org.openqa.selenium.OutputType<X> outputType)
    Captures a screenshot of this element in the requested output form.
    Find selected option from this select field
    Get text of selected option in select field
    Get value of selected option in select field
    org.openqa.selenium.SearchContext
    Returns the shadow root hosted by this element, allowing queries into its shadow DOM.
    org.openqa.selenium.Dimension
     
     
    Get the visible text of this element
    Get the currently selected (highlighted) text of this element.
    Get the "value" attribute of the element
    com.workfusion.rpa.internal.api.element.WebElement
    Returns the underlying WebElement this object wraps.
    boolean
    has(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Return true iff element matches given condition
    int
     
    Emulate "mouseOver" event.
    Get the HTML code of the element with children.
    Get the text code of the element with children.
    boolean
    is(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Return true if element matches given condition
    boolean
     
    boolean
     
    boolean
    Deprecated.
    from 9.2, it will be delete in 10.0
    boolean
    Check if image is properly loaded.
    boolean
     
    int
    Left edge of the element in element-local coordinates (relative to its top-left corner).
    Get the "name" attribute of the element
    Get parent element of this element For example, $("td").parent() could give some "tr".
    Press BACK_SPACE.
    Send CTRL+A.
    Send CTRL+C.
    Send CTRL+SHIFT+Z.
    Send CTRL+V.
    Send CTRL+X.
    Send CTRL+Z.
    Press ENTER.
    Press ESCAPE.
    Press SPACE.
    Press TAB.
    int
    Right edge of the element in element-local coordinates (relative to its top-left corner).
    scrollDown(int times)
    Moves mouse cursor to the center of element and scrolls down number of times.
    Ask browser to scroll to this element
    scrollUp(int times)
    Moves mouse cursor to the center of element and scrolls up number of times.
    Sample: String selectedText = $("[CLASS:Edit; INSTANCE:1]") .append("some text") .selectAllTextAndCopy();
    selectOption(int index)
    Select an option from dropdown list (by index)
    Select an option from dropdown list (by text)
    Select an option from dropdown list (by value)
    void
    sendKeys(CharSequence... charSequences)
    Types the given key sequence into the element.
    Types the given value into the element, converting it to text first.
    It scrolls to the element, moves cursor to it and then performs sendKeys.
    setSelected(boolean selected)
    Set checkbox/radio state to CHECKED or UNCHECKED.
    Sets given text to a text field
    Clear the text field and enter given text.
    should(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Checks that given element meets all of given conditions.
    should(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
    Checks that the element meets all of the given conditions immediately (no waiting).
    should(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition1, com.workfusion.rpa.helpers.conditionsnative.UiCondition condition2)
    Checks that the element meets both of the given conditions immediately (no waiting).
    shouldBe(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Synonym for should(UiCondition) reading as "be"; checked immediately.
    shouldBe(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
    shouldHave(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Synonym for should(UiCondition) reading as "have"; checked immediately.
    shouldHave(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
    shouldNot(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Checks that the element does NOT meet the given condition immediately (no waiting).
    shouldNot(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
    Checks that given element does not meet given conditions.
    shouldNotBe(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Synonym for shouldNot(UiCondition) reading as "not be"; checked immediately.
    shouldNotBe(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
    shouldNotHave(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Synonym for shouldNot(UiCondition) reading as "not have"; checked immediately.
    shouldNotHave(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
    Single click the element.
    singleClick(int offsetX, int offsetY)
    Single click the element.
    boolean
    Checks if element still exists on the current page.
    void
    Submits the form this element belongs to (or the element itself if it is a form).
    Short form of getText()
    text(Object text)
    Driver Type: Desktop, Web
    int
    top()
    Top edge of the element in element-local coordinates (relative to its top-left corner).
    org.openqa.selenium.support.ui.Select
    Converts UI element to Select
    Displays WebElement in human-readable format.
    com.workfusion.rpa.internal.api.element.WebElement
     
    Triple click the element
    tripleClick(int offsetX, int offsetY)
    Triple-click the element at a point offset from its TOP-LEFT corner.
    val()
    Get the "value" attribute of the element Same as #getValue()
    val(Object text)
    Driver Type: Desktop, Web
    waitUntil(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Wait until given element meets given conditions.
    waitUntil(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition, long timeoutMilliseconds)
    Wait until given element meets given conditions.
    waitUntil(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition, long timeoutMilliseconds, long pollingIntervalMilliseconds)
    Wait until given element meets given conditions.
    waitWhile(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Wait while given element meets given conditions.
    waitWhile(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition, long timeoutMilliseconds)
    Wait while given element meets given conditions.
    waitWhile(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition, long timeoutMilliseconds, long pollingIntervalMilliseconds)
    Wait while given element meets given conditions.
    Wheel click on the element
    wheelClick(int offsetX, int offsetY)
    Middle-button (wheel) click the element at a point offset from its TOP-LEFT corner.

    Methods inherited from class java.lang.Object

    getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface com.workfusion.rpa.internal.api.element.WebElement

    setText
  • Method Details

    • append

      public UiElement append(Object text)

      Append given text to the text field.

      This is the same as WebElement.sendKeys(text)

      Driver Type: Desktop, Web

      Parameters:
      text - Any text to append into the text field.
    • setValue

      public UiElement setValue(Object text)

      Clear the text field and enter given text.

      Implementation details: this is the same as

         1. WebElement.clear()
         2. WebElement.sendKeys(text)

      Driver Type: Desktop, Web

      Parameters:
      text - Any text to enter into the text field.
    • val

      public UiElement val(Object text)

      Driver Type: Desktop, Web

      Same as #setValue(java.lang.String)

    • text

      public UiElement text(Object text)

      Driver Type: Desktop, Web

      Same as #setValue(java.lang.String)

    • setText

      public UiElement setText(Object text)

      Sets given text to a text field

      Driver Type: Desktop, Web

      Parameters:
      text - Any text to enter into the text field.
    • pressEnter

      public UiElement pressEnter()
      Press ENTER. Useful for input field and textareas:
        $("query").val("Aikido techniques").pressEnter();

      Implementation details: This is the same as

        WebElement.sendKeys(Keys.ENTER)

      Driver Type: Desktop, Web

    • pressTab

      public UiElement pressTab()
      Press TAB. Useful for input field and textareas:
        $("#to").val("stiven@seagal.com").pressTab();

      Implementation details: This is the same as

        WebElement.sendKeys(Keys.TAB)

      Driver Type: Desktop, Web

    • pressEscape

      public UiElement pressEscape()
      Press ESCAPE. Useful for input field and textareas:
        $(".edit").click().pressEscape();

      Implementation details: This is the same as

        WebElement.sendKeys(Keys.ESCAPE)

      Driver Type: Desktop, Web

    • pressSpace

      public UiElement pressSpace()
      Press SPACE. Useful for input field and textareas:
        $(".edit").pressSpace();

      Implementation details: This is the same as

        WebElement.sendKeys(Keys.SPACE)

      Driver Type: Desktop, Web

    • pressBackSpace

      public UiElement pressBackSpace()
      Press BACK_SPACE. Useful for input field and textareas:
        $(".edit").pressBackSpace();

      Implementation details: This is the same as

        WebElement.sendKeys(Keys.BACK_SPACE)

      Driver Type: Desktop, Web

    • pressCtrlA

      public UiElement pressCtrlA()
      Send CTRL+A. Useful for input field and textareas:
       $(".edit").pressCtrlA();

      Implementation details: This is the same as

       WebElement.sendKeys.sendKeys(Keys.chord(Keys.CONTROL, "a"))

      Driver Type: Desktop, Web

    • pressCtrlC

      public UiElement pressCtrlC()
      Send CTRL+C. Useful for input field and textareas:
       $(".edit").pressCtrlC();

      Implementation details: This is the same as

       WebElement.sendKeys.sendKeys(Keys.chord(Keys.CONTROL, "c"))

      Driver Type: Desktop, Web

    • pressCtrlV

      public UiElement pressCtrlV()
      Send CTRL+V. Useful for input field and textareas:
       $(".edit").pressCtrlV();

      Implementation details: This is the same as

       WebElement.sendKeys(Keys.chord(Keys.CONTROL, "v"))

      Driver Type: Desktop, Web

    • pressCtrlX

      public UiElement pressCtrlX()
      Send CTRL+X. Useful for input field and textareas:
       $(".edit").pressCtrlX();

      Implementation details: This is the same as

       WebElement.sendKeys(Keys.chord(Keys.CONTROL, "x"))

      Driver Type: Desktop, Web

    • pressCtrlZ

      public UiElement pressCtrlZ()
      Send CTRL+Z. Useful for input field and textareas:
       $(".edit").pressCtrlZ();

      Implementation details: This is the same as

       WebElement.sendKeys(Keys.chord(Keys.CONTROL, "z"))

      Driver Type: Desktop, Web

    • pressCtrlShiftZ

      public UiElement pressCtrlShiftZ()
      Send CTRL+SHIFT+Z. Useful for input field and textareas:
       $(".edit").pressCtrlShiftZ();

      Implementation details: This is the same as

       WebElement.sendKeys(Keys.chord(Keys.CONTROL, Keys.SHIFT, "z"))

      Driver Type: Desktop, Web

    • getText

      public String getText()
      Get the visible text of this element

      Driver Type: Desktop, Web

      Specified by:
      getText in interface org.openqa.selenium.WebElement
      Returns:
      The text of this element
    • getTextSelected

      public String getTextSelected()
      Get the currently selected (highlighted) text of this element.

      Driver Type: Desktop, Web

      Specified by:
      getTextSelected in interface com.workfusion.rpa.internal.api.element.WebElement
      Returns:
      the selected text, or an empty string if nothing is selected
    • text

      public String text()
      Short form of getText()

      Driver Type: Desktop, Web

      See Also:
      • WebElement.getText()
    • innerText

      public String innerText()
      Get the text code of the element with children.

      Driver Type: Web

      Short form of getAttribute("textContent") or getAttribute("innerText") depending on browser.

    • innerHtml

      public String innerHtml()
      Get the HTML code of the element with children.

      Short form of getAttribute("innerHTML")

      Driver Type: Web

    • attr

      public String attr(String attributeName)
      Get the attribute of the element. Synonym for getAttribute(String).

      Driver Type: Desktop, Web

      Returns:
      null if attribute is missing
    • name

      public String name()
      Get the "name" attribute of the element

      Driver Type: Desktop, Web

      Returns:
      attribute "name" value or null if attribute is missing
    • val

      public String val()
      Get the "value" attribute of the element Same as #getValue()

      Driver Type: Desktop, Web

      Returns:
      attribute "value" value or null if attribute is missing
    • getValue

      public String getValue()
      Get the "value" attribute of the element

      Driver Type: Desktop, Web

      Returns:
      attribute "value" value or null if attribute is missing
    • isExists

      @Deprecated public boolean isExists()
      Deprecated.
      from 9.2, it will be delete in 10.0
      Checks if element exists true on the current page.

      Driver Type: Desktop, Web

      Returns:
      false if element is not found, browser is closed or any WebDriver exception happened
    • stillExists

      public boolean stillExists()
      Checks if element still exists on the current page.

      Driver Type: Desktop, Web

      Returns:
      false if element is not found, browser is closed or any WebDriver exception happened
      Since:
      9.2
    • is

      public boolean is(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
      Return true if element matches given condition

      Driver Type: Desktop, Web

    • has

      public boolean has(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
      Return true iff element matches given condition

      Driver Type: Desktop, Web

    • should

      public UiElement should(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)

      Checks that given element meets all of given conditions.

      IMPORTANT: Element matches these conditions immediately.

      For example: $("#errorMessage").should(APPEAR);

      Driver Type: Desktop, Web

      Returns:
      Given element, useful for chaining: $("#errorMessage").should(APPEAR).shouldBe(ENABLED);
      Throws:
      IllegalStateException - if element is not matched to condition
    • should

      public UiElement should(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
      Checks that the element meets all of the given conditions immediately (no waiting).

      Driver Type: Desktop, Web

      Parameters:
      conditions - conditions that must all hold
      Returns:
      this element, for chaining
      Throws:
      IllegalStateException - if any condition is not met
      See Also:
    • should

      public UiElement should(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition1, com.workfusion.rpa.helpers.conditionsnative.UiCondition condition2)
      Checks that the element meets both of the given conditions immediately (no waiting).

      Driver Type: Desktop, Web

      Parameters:
      condition1 - first condition that must hold
      condition2 - second condition that must hold
      Returns:
      this element, for chaining
      Throws:
      IllegalStateException - if either condition is not met
      See Also:
    • shouldHave

      public UiElement shouldHave(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)

      Synonym for should(UiCondition...)}. Useful for better readability.

      For example: $("#errorMessage").shouldHave(text("Hello"), text("World"));

      Driver Type: Desktop, Web

      See Also:
    • shouldHave

      public UiElement shouldHave(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
      Synonym for should(UiCondition) reading as "have"; checked immediately.

      Driver Type: Desktop, Web

      Parameters:
      condition - condition that must hold
      Returns:
      this element, for chaining
      Throws:
      IllegalStateException - if the condition is not met
    • shouldBe

      public UiElement shouldBe(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)

      Synonym for should(UiCondition...)}. Useful for better readability.

      For example: $("#errorMessage").shouldBe(visible, enabled);

      Driver Type: Desktop, Web

      See Also:
    • shouldBe

      public UiElement shouldBe(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
      Synonym for should(UiCondition) reading as "be"; checked immediately.

      Driver Type: Desktop, Web

      Parameters:
      condition - condition that must hold
      Returns:
      this element, for chaining
      Throws:
      IllegalStateException - if the condition is not met
    • shouldNot

      public UiElement shouldNot(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)

      Checks that given element does not meet given conditions.

      IMPORTANT: If element matches these conditions immediately.

      For example: $("#errorMessage").should(exist);

      Driver Type: Desktop, Web

    • shouldNot

      public UiElement shouldNot(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
      Checks that the element does NOT meet the given condition immediately (no waiting).

      Driver Type: Desktop, Web

      Parameters:
      condition - condition that must not hold
      Returns:
      this element, for chaining
      Throws:
      IllegalStateException - if the condition is met
    • shouldNotHave

      public UiElement shouldNotHave(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)

      Synonym for shouldNot(UiCondition...). Useful for better readability.

      For example: $("#errorMessage").shouldNotHave(text("Exception"), text("Error"));

      Driver Type: Desktop, Web

      See Also:
    • shouldNotHave

      public UiElement shouldNotHave(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
      Synonym for shouldNot(UiCondition) reading as "not have"; checked immediately.

      Driver Type: Desktop, Web

      Parameters:
      condition - condition that must not hold
      Returns:
      this element, for chaining
      Throws:
      IllegalStateException - if the condition is met
    • shouldNotBe

      public UiElement shouldNotBe(com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)

      Synonym for shouldNot(UiCondition...). Useful for better readability.

      For example: $("#errorMessage").shouldNotBe(visible, enabled);

      Driver Type: Desktop, Web

      See Also:
    • shouldNotBe

      public UiElement shouldNotBe(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
      Synonym for shouldNot(UiCondition) reading as "not be"; checked immediately.

      Driver Type: Desktop, Web

      Parameters:
      condition - condition that must not hold
      Returns:
      this element, for chaining
      Throws:
      IllegalStateException - if the condition is met
    • waitUntil

      public UiElement waitUntil(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)

      Wait until given element meets given conditions.

      Driver Type: Desktop, Web

      Parameters:
      condition - e.g. enabled, visible, text() and so on
      Throws:
      IllegalStateException - if element still is not matched to condition after the timeout
    • waitUntil

      public UiElement waitUntil(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition, long timeoutMilliseconds)

      Wait until given element meets given conditions.

      Driver Type: Desktop, Web

      Parameters:
      condition - e.g. enabled, visible, text() and so on
      timeoutMilliseconds - timeout in milliseconds.
      Throws:
      IllegalStateException - if element still is not matched to condition after the timeout
    • waitUntil

      public UiElement waitUntil(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition, long timeoutMilliseconds, long pollingIntervalMilliseconds)

      Wait until given element meets given conditions.

      Driver Type: Desktop, Web

      Parameters:
      condition - e.g. enabled, visible, text() and so on
      timeoutMilliseconds - timeout in milliseconds.
      pollingIntervalMilliseconds - interval in milliseconds, when checking condition
      Throws:
      IllegalStateException - if element still is not matched to condition after the timeout
    • waitWhile

      public UiElement waitWhile(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)

      Wait while given element meets given conditions.

      Driver Type: Desktop, Web

      Parameters:
      condition - e.g. enabled, visible, text() and so on
      Throws:
      IllegalStateException - if element still is not matched to condition after the timeout
    • waitWhile

      public UiElement waitWhile(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition, long timeoutMilliseconds)

      Wait while given element meets given conditions.

      Driver Type: Desktop, Web

      Parameters:
      condition - e.g. enabled, visible, text() and so on
      timeoutMilliseconds - timeout in milliseconds.
      Throws:
      IllegalStateException - if element still is not matched to condition after the timeout
    • waitWhile

      public UiElement waitWhile(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition, long timeoutMilliseconds, long pollingIntervalMilliseconds)

      Wait while given element meets given conditions.

      Driver Type: Desktop, Web

      Parameters:
      condition - e.g. enabled, visible, text() and so on
      timeoutMilliseconds - timeout in milliseconds.
      pollingIntervalMilliseconds - interval in milliseconds, when checking condition
      Throws:
      IllegalStateException - if element still is not matched to condition after the timeout
    • parent

      public UiElement parent()
      Get parent element of this element For example, $("td").parent() could give some "tr".

      Driver Type: Web

      Returns:
      Parent element
    • closest

      public UiElement closest(String tagOrClass)
      Find closes ancestor element matching given criteria. For example, $("td").closest("table") could give some "table".

      Driver Type: Web

      Parameters:
      tagOrClass - Either HTML tag or CSS class. E.g. "form" or ".active".
      Returns:
      Matching ancestor element
    • find

      public UiElement find(String cssSelector)

      Find the first matching element inside given element

      Short form of webElement.findElement(By.cssSelector(cssSelector))

      Driver Type: Desktop, Web

    • find

      public UiElement find(String cssSelector, int index)

      Find the Nth matching element inside given element

      Driver Type: Desktop, Web

    • find

      public UiElement find(org.openqa.selenium.By selector)

      Find the first matching element inside given element

      Short form of webElement.findElement(By.cssSelector(cssSelector))

      Driver Type: Desktop, Web

    • find

      public UiElement find(org.openqa.selenium.By selector, int index)

      Find the Nth matching element inside given element

      Driver Type: Desktop, Web

    • $

      public UiElement $(String cssSelector)

      Driver Type: Desktop, Web

      See Also:
    • $

      public UiElement $(String cssSelector, int index)

      Driver Type: Desktop, Web

      UiElement#find(java.lang.String)
    • $

      public UiElement $(org.openqa.selenium.By selector)

      Driver Type: Desktop, Web

      UiElement#find(java.lang.String)

    • $

      public UiElement $(org.openqa.selenium.By selector, int index)

      Driver Type: Desktop, Web

      UiElement#find(java.lang.String)

    • findAll

      public UiElementCollection findAll(String cssSelector)

      Short form of webDriver.findElements(thisElement, By.cssSelector(cssSelector))

      For example, $("#multirowTable").findAll("tr.active").shouldHave(size(2));

      Driver Type: Desktop, Web

      Returns:
      list of elements inside given element matching given CSS selector
    • findAll

      public UiElementCollection findAll(org.openqa.selenium.By selector)

      Short form of webDriver.findElements(thisElement, selector)

      For example, $("#multirowTable").findAll(By.className("active")).shouldHave(size(2));

      Driver Type: Desktop, Web

      Returns:
      list of elements inside given element matching given criteria
    • $$

      public UiElementCollection $$(String cssSelector)

      Driver Type: Desktop, Web

      UiElement#findAll(java.lang.String)

    • $$

      public UiElementCollection $$(org.openqa.selenium.By selector)

      Driver Type: Desktop, Web

      UiElement#findAll(java.lang.String)

    • setSelected

      public UiElement setSelected(boolean selected)
      Set checkbox/radio state to CHECKED or UNCHECKED.

      Driver Type: Desktop, Web

      Parameters:
      selected - true for checked and false for unchecked
    • toSelectElement

      public org.openqa.selenium.support.ui.Select toSelectElement()
      Converts UI element to Select

      Driver Type: Web

      Returns:
      Select object that Models a SELECT tag, providing helper methods to select and deselect options.
    • selectOption

      public UiElement selectOption(int index)
      Select an option from dropdown list (by index)

      Driver Type: Web

      Parameters:
      index - 0..N (0 means first option)
    • selectOption

      public UiElement selectOption(String text)
      Select an option from dropdown list (by text)

      Driver Type: Web

      Parameters:
      text - visible text of option
    • selectOptionByValue

      public UiElement selectOptionByValue(String value)
      Select an option from dropdown list (by value)

      Driver Type: Web

      Parameters:
      value - "value" attribute of option
    • getSelectedOption

      public UiElement getSelectedOption()
      Find selected option from this select field

      Driver Type: Web

      Returns:
      WebElement for selected <option> element
    • getSelectedValue

      public String getSelectedValue()
      Get value of selected option in select field

      Driver Type: Web

    • getSelectedText

      public String getSelectedText()
      Get text of selected option in select field

      Driver Type: Web

    • scrollTo

      public UiElement scrollTo()
      Ask browser to scroll to this element

      Driver Type: Web

    • scrollDown

      public UiElement scrollDown(int times)
      Moves mouse cursor to the center of element and scrolls down number of times.

      Driver Type: Desktop, Web

      Parameters:
      times - how many times need to scroll (ticks of the mouse wheel)
      Returns:
      this element
    • scrollUp

      public UiElement scrollUp(int times)
      Moves mouse cursor to the center of element and scrolls up number of times.

      Driver Type: Desktop, Web

      Parameters:
      times - how many times need to scroll (ticks of the mouse wheel)
      Returns:
      this element
    • toWebElement

      public com.workfusion.rpa.internal.api.element.WebElement toWebElement()
      Returns:
      the original Selenium WebElement wrapped by this object
    • getWrappedElement

      public com.workfusion.rpa.internal.api.element.WebElement getWrappedElement()
      Returns the underlying WebElement this object wraps. Unlike toWebElement(), it unwraps only one level, so the result may itself be another UiElement.
      Specified by:
      getWrappedElement in interface org.openqa.selenium.WrapsElement
      Returns:
      the wrapped element
    • click

      public UiElement click(int offsetX, int offsetY)
      Left-click the element at a point offset from its TOP-LEFT corner.

      The offset is measured from the element's top-left corner ((0, 0)), not from its center as the Selenium 4 Actions API would; the conversion is done internally via recalculateOffsetToCenter(int, int). For example click(5, 5) clicks 5px right and 5px down from the top-left corner, while click(centerX(), centerY()) clicks the center. See the class-level "Coordinates and offsets" section.

      Driver Type: Desktop, Web

      Parameters:
      offsetX - horizontal offset from the element's left edge, in pixels (grows to the right)
      offsetY - vertical offset from the element's top edge, in pixels (grows downward)
      Since:
      9.2
    • click

      public void click()
      Click the element

      By default it uses default Selenium method click.

      Specified by:
      click in interface org.openqa.selenium.WebElement
    • contextClick

      public UiElement contextClick(int offsetX, int offsetY)
      Right-click (context-click) the element at a point offset from its TOP-LEFT corner.

      The offset is measured from the element's top-left corner ((0, 0)); see the class-level "Coordinates and offsets" section.

      Driver Type: Desktop, Web

      Parameters:
      offsetX - horizontal offset from the element's left edge, in pixels (grows to the right)
      offsetY - vertical offset from the element's top edge, in pixels (grows downward)
      Returns:
      this element
      Since:
      9.2
    • contextClick

      public UiElement contextClick()
      Click with right mouse button on this element
      Returns:
      this element
    • singleClick

      public UiElement singleClick(int offsetX, int offsetY)
      Single click the element. The same as click(int, int), but returns UiElement. Helpful for chaining
      Sample
      $("[CLASS:Edit; INSTANCE:1]").singleClick(10, 10).sendKeys(text);

      The offset is measured from the element's top-left corner ((0, 0)); see the class-level "Coordinates and offsets" section.

      Driver Type: Desktop, Web

      Parameters:
      offsetX - horizontal offset from the element's left edge, in pixels (grows to the right)
      offsetY - vertical offset from the element's top edge, in pixels (grows downward)
      Returns:
      this UiElement
      Since:
      9.2
    • singleClick

      public UiElement singleClick()
      Single click the element. The same as click(), but returns UiElement. Helpful for chaining
      Sample
      $("[CLASS:Edit; INSTANCE:1]").singleClick().sendKeys(text);
      Returns:
      this UiElement
    • doubleClick

      public UiElement doubleClick(int offsetX, int offsetY)
      Double-click the element at a point offset from its TOP-LEFT corner.

      The offset is measured from the element's top-left corner ((0, 0)); see the class-level "Coordinates and offsets" section.

      Driver Type: Desktop, Web

      Parameters:
      offsetX - horizontal offset from the element's left edge, in pixels (grows to the right)
      offsetY - vertical offset from the element's top edge, in pixels (grows downward)
      Returns:
      this UiElement
      Since:
      9.2
    • doubleClick

      public UiElement doubleClick()
      Double click the element
      Returns:
      this element
    • tripleClick

      public UiElement tripleClick(int offsetX, int offsetY)
      Triple-click the element at a point offset from its TOP-LEFT corner.

      The offset is measured from the element's top-left corner ((0, 0)); see the class-level "Coordinates and offsets" section.

      Driver Type: Desktop, Web

      Parameters:
      offsetX - horizontal offset from the element's left edge, in pixels (grows to the right)
      offsetY - vertical offset from the element's top edge, in pixels (grows downward)
      Returns:
      this UiElement
      Since:
      9.2
    • tripleClick

      public UiElement tripleClick()
      Triple click the element

      Driver Type: Desktop, Web

      Returns:
      this element
    • click

      public UiElement click(int clicks, int offsetX, int offsetY)
      Left-click the element a given number of times at a point offset from its TOP-LEFT corner.

      The offset is measured from the element's top-left corner ((0, 0)); see the class-level "Coordinates and offsets" section. All clicks land on the same point.

      Driver Type: Desktop, Web

      Parameters:
      clicks - number of consecutive clicks to perform
      offsetX - horizontal offset from the element's left edge, in pixels (grows to the right)
      offsetY - vertical offset from the element's top edge, in pixels (grows downward)
      Returns:
      this UiElement
      Since:
      9.2
    • click

      public UiElement click(int clicks)
      Click the element number of times

      Driver Type: Desktop, Web

      Parameters:
      clicks - number of clicks
      Returns:
      this element
    • wheelClick

      public UiElement wheelClick(int offsetX, int offsetY)
      Middle-button (wheel) click the element at a point offset from its TOP-LEFT corner.

      The offset is measured from the element's top-left corner ((0, 0)); see the class-level "Coordinates and offsets" section.

      Driver Type: Desktop, Web

      Parameters:
      offsetX - horizontal offset from the element's left edge, in pixels (grows to the right)
      offsetY - vertical offset from the element's top edge, in pixels (grows downward)
      Returns:
      this UiElement
      Since:
      9.2
    • wheelClick

      public UiElement wheelClick()
      Wheel click on the element

      Driver Type: Desktop, Web

      Returns:
      this element
    • hover

      public UiElement hover()
      Emulate "mouseOver" event. In other words, move mouse cursor over this element (without clicking it).
      Returns:
      this element
    • isImageLoaded

      public boolean isImageLoaded()
      Check if image is properly loaded.

      Driver Type: Web

      Throws:
      IllegalArgumentException - if argument is not an "img" element
    • submit

      public void submit()
      Submits the form this element belongs to (or the element itself if it is a form).

      Driver Type: Web

      Specified by:
      submit in interface org.openqa.selenium.WebElement
    • sendKeys

      public void sendKeys(CharSequence... charSequences)
      Types the given key sequence into the element.

      Driver Type: Desktop, Web

      Specified by:
      sendKeys in interface org.openqa.selenium.WebElement
      Parameters:
      charSequences - the characters/keys to send (may include Keys values)
    • sendKeys

      public UiElement sendKeys(Object text)
      Types the given value into the element, converting it to text first. Unlike sendKeys(CharSequence...) this returns the element for chaining.

      Driver Type: Desktop, Web

      Parameters:
      text - the value to type; converted to its string form before sending
      Returns:
      this element, for chaining
    • sendKeysWithFocus

      public UiElement sendKeysWithFocus(Object text)
      It scrolls to the element, moves cursor to it and then performs sendKeys. Above actions help to maintain focus on the element before sendKeys is invoked, which leads to improved reliability of sendKeys action.

      Driver Type: Web

      Returns:
      this element
      Throws:
      IllegalStateException - if driver different than Web is used
      Since:
      10.2.7
    • clear

      public void clear()
      Clears the text of this input or textarea element.

      Driver Type: Desktop, Web

      Specified by:
      clear in interface org.openqa.selenium.WebElement
    • getTagName

      public String getTagName()
      Specified by:
      getTagName in interface org.openqa.selenium.WebElement
      Returns:
      the tag name of this element (e.g. "input"); for Desktop, the control type
    • getAttribute

      public String getAttribute(String s)
      Gets the value of the given attribute.
      Specified by:
      getAttribute in interface org.openqa.selenium.WebElement
      Parameters:
      s - the attribute name
      Returns:
      the attribute value, or null if the attribute is missing
    • getDomAttribute

      public String getDomAttribute(String name)
      Gets the value of the given attribute as declared in the DOM markup, without any property normalization.

      Driver Type: Web

      Specified by:
      getDomAttribute in interface org.openqa.selenium.WebElement
      Parameters:
      name - the attribute name
      Returns:
      the declared attribute value, or null if it is not present
    • getDomProperty

      public String getDomProperty(String name)
      Gets the value of the given DOM property (the current, possibly script-updated value), as opposed to the static markup attribute.

      Driver Type: Web

      Specified by:
      getDomProperty in interface org.openqa.selenium.WebElement
      Parameters:
      name - the property name
      Returns:
      the property value, or null if it is not present
    • getAriaRole

      public String getAriaRole()
      Specified by:
      getAriaRole in interface org.openqa.selenium.WebElement
      Returns:
      the ARIA role of this element (explicit role attribute or its implicit role)

      Driver Type: Web

    • getAccessibleName

      public String getAccessibleName()
      Specified by:
      getAccessibleName in interface org.openqa.selenium.WebElement
      Returns:
      the accessible name of this element, as computed for assistive technologies

      Driver Type: Web

    • getShadowRoot

      public org.openqa.selenium.SearchContext getShadowRoot()
      Returns the shadow root hosted by this element, allowing queries into its shadow DOM.

      Driver Type: Web

      Specified by:
      getShadowRoot in interface org.openqa.selenium.WebElement
      Returns:
      the shadow root as a SearchContext
    • isSelected

      public boolean isSelected()
      Specified by:
      isSelected in interface org.openqa.selenium.WebElement
      Returns:
      true if this element (e.g. a checkbox, radio button or option) is selected
    • isEnabled

      public boolean isEnabled()
      Specified by:
      isEnabled in interface org.openqa.selenium.WebElement
      Returns:
      true if this element is enabled (not disabled)
    • focus

      public boolean focus()
      Sets input focus on this element.

      Driver Type: Desktop

      Specified by:
      focus in interface com.workfusion.rpa.internal.api.element.WebElement
      Returns:
      true if the element received focus
    • isDisplayed

      public boolean isDisplayed()
      Specified by:
      isDisplayed in interface org.openqa.selenium.WebElement
      Returns:
      true if this element is rendered and visible to the user
    • findElements

      public List<org.openqa.selenium.WebElement> findElements(org.openqa.selenium.By by)
      Finds all descendant elements matching the given criteria.
      Specified by:
      findElements in interface org.openqa.selenium.SearchContext
      Specified by:
      findElements in interface org.openqa.selenium.WebElement
      Parameters:
      by - the locating criteria
      Returns:
      the matching elements (empty list if none)
    • findElement

      public com.workfusion.rpa.internal.api.element.WebElement findElement(org.openqa.selenium.By by)
      Finds the first descendant element matching the given criteria.
      Specified by:
      findElement in interface org.openqa.selenium.SearchContext
      Specified by:
      findElement in interface org.openqa.selenium.WebElement
      Parameters:
      by - the locating criteria
      Returns:
      the first matching element
      Throws:
      org.openqa.selenium.NoSuchElementException - if no element matches
    • getLocation

      public org.openqa.selenium.Point getLocation()
      Specified by:
      getLocation in interface org.openqa.selenium.WebElement
      Returns:
      the location of the element's top-left corner (page pixels on Web, screen pixels on Desktop)
    • getSize

      public org.openqa.selenium.Dimension getSize()
      Specified by:
      getSize in interface org.openqa.selenium.WebElement
      Returns:
      the width and height of the element, in pixels
    • getRect

      public org.openqa.selenium.Rectangle getRect()
      Specified by:
      getRect in interface org.openqa.selenium.WebElement
      Returns:
      the element's bounding rectangle (location of its top-left corner plus its size)
    • getCssValue

      public String getCssValue(String s)
      Gets the value of a CSS property of this element.

      Driver Type: Web

      Specified by:
      getCssValue in interface org.openqa.selenium.WebElement
      Parameters:
      s - the CSS property name
      Returns:
      the property value
    • getScreenshotAs

      public <X> X getScreenshotAs(org.openqa.selenium.OutputType<X> outputType)
      Captures a screenshot of this element in the requested output form.
      Specified by:
      getScreenshotAs in interface org.openqa.selenium.TakesScreenshot
      Type Parameters:
      X - the output type
      Parameters:
      outputType - the desired output format (e.g. OutputType.FILE, OutputType.BYTES)
      Returns:
      the screenshot in the requested form
    • getId

      public String getId()
      Specified by:
      getId in interface com.workfusion.rpa.internal.api.element.WebElement
      Returns:
      the internal driver-assigned identifier of this element
    • getCoordinates

      public org.openqa.selenium.interactions.Coordinates getCoordinates()
      Returns the Coordinates of this element, used by mouse interactions to address it. The point reported is the element's location; see RobotsMouse for how it is used.
      Specified by:
      getCoordinates in interface org.openqa.selenium.interactions.Locatable
      Returns:
      this element's coordinates
    • copySelectedText

      public String copySelectedText()
      Copies selected text

      Driver Type: Desktop

      Returns:
      selected text
    • selectAllTextAndCopy

      public String selectAllTextAndCopy()
      Sample: String selectedText = $("[CLASS:Edit; INSTANCE:1]") .append("some text") .selectAllTextAndCopy();

      Driver Type: Desktop

      Returns:
      selected text
    • equals

      public boolean equals(Object o)
      Two UiElements are equal when they are of the same class and wrap equal underlying elements.
      Overrides:
      equals in class Object
      Parameters:
      o - the object to compare with
      Returns:
      true if the other object wraps the same element
    • top

      public int top()
      Top edge of the element in element-local coordinates (relative to its top-left corner).

      Always 0, since the element's own origin is its top-left corner. Provided for symmetry with bottom() and so it can be used as an offset, e.g. click(left(), top()) clicks the top-left corner.

      Returns:
      0
    • left

      public int left()
      Left edge of the element in element-local coordinates (relative to its top-left corner).

      Always 0, since the element's own origin is its top-left corner. Provided for symmetry with right() and so it can be used as an offset.

      Returns:
      0
    • bottom

      public int bottom()
      Bottom edge of the element in element-local coordinates (relative to its top-left corner).
      Returns:
      the element height, in pixels
    • right

      public int right()
      Right edge of the element in element-local coordinates (relative to its top-left corner).
      Returns:
      the element width, in pixels
    • centerX

      public int centerX()
      Horizontal center of the element relative to its top-left corner.

      Can be passed directly as an offsetX to the offset-based mouse methods, e.g. click(centerX(), centerY()) clicks the element's center.

      Returns:
      half of the element width, in pixels
    • centerY

      public int centerY()
      Vertical center of the element relative to its top-left corner.

      Can be passed directly as an offsetY to the offset-based mouse methods, e.g. click(centerX(), centerY()) clicks the element's center.

      Returns:
      half of the element height, in pixels
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      a hash code consistent with equals(Object), derived from the wrapped element
    • toString

      public String toString()
      Displays WebElement in human-readable format. Useful for logging and debugging. Not recommended to use for test verifications.
      Overrides:
      toString in class Object