Class UiConditions

java.lang.Object
com.workfusion.rpa.helpers.UiConditions

public class UiConditions extends Object
This class provides human-readable condition logic.
Samples
$("input").shouldBe(VISIBLE);
$("#logoutLink").should(APPEAR);
$.shouldNot(exist);
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Synonym for VISIBLE - may be used for better readability Sample $("#logoutLink").should(APPEAR);
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Synonym for VISIBLE - may be used for better readability
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Checks that element is disabled
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Synonym for HIDDEN - may be used for better readability:
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Synonym for HIDDEN - may be used for better readability:
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    1) For input element, checks that value is missing or empty
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Checks that element is not disabled
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Check that element exists.
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Check if browser focus is currently on a given element.
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Checks that element is not visible or does not exists.
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Checks that element is present on the page.
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Check if element has "readonly" attribute (with any value)
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Checks that element is selected
    static final com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Checks that element is visible Sample $("input").shouldBe(VISIBLE);
  • Method Summary

    Modifier and Type
    Method
    Description
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    and(String name, com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
    Check if element matches ALL given conditions.
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    attribute(String attributeName)
    Checks that element has a given attribute (with any value)
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    attribute(String attributeName, String expectedAttributeValue)
    Checks that current element has an attribute with specified value
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    be(com.workfusion.rpa.helpers.conditionsnative.UiCondition delegate)
    Used to form human-readable condition expression Example element.should(be(VISIBLE),have(text("abc"))
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    cssClass(String cssClass)
    Sample: $("input").shouldHave(cssClass("active"));
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    hasAttribute(String attributeName, String attributeValue)
    Checks that current element has an attribute with specified value
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    hasClass(String cssClass)
    Sample: $("input").waitUntil(hasClass("blocked"), 7000);
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    hasPartialValue(String expectedPartOfValue)
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Asserts that element has specified text content
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    hasValue(String expectedValue)
    Synonym for value(String)
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    have(com.workfusion.rpa.helpers.conditionsnative.UiCondition delegate)
    Used to form human-readable condition expression Example element.should(be(VISIBLE),have(text("abc"))
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    id(String id)
    Asserts that element has given "id" attribute as substring
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Assert that given element's text matches given regular expression
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    name(String name)
    Asserts that element has given "name" attribute as substring
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    not(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
    Negate given condition.
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    or(String name, com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
    Check if element matches ANY of given conditions.
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    partialValue(String expectedPartOfValue)
    Asserts that element has given "value" attribute as substring
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    text(String text)
    Asserts that element has specified text content
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    Asserts that element has specified text content
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    type(String type)
    Asserts that element has given "type" attribute as substring
    static com.workfusion.rpa.helpers.conditionsnative.UiCondition
    value(String expectedValue)
    Asserts that element has given "value" attribute as substring

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • ENABLED

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition ENABLED
      Checks that element is not disabled
      See Also:
      • WebElement.isEnabled()
    • DISABLED

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition DISABLED
      Checks that element is disabled
      See Also:
      • WebElement.isEnabled()
    • VISIBLE

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition VISIBLE
      Checks that element is visible
      Sample
      $("input").shouldBe(VISIBLE);
      See Also:
      • WebElement.isDisplayed()
    • EXIST

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition EXIST
      Check that element exists. It can be visible or hidden.
      Sample
      $("input").should(EXIST);
    • PRESENT

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition PRESENT
      Checks that element is present on the page. Synonym for EXIST.
      Sample
      $("input").shouldBe(PRESENT);
    • HIDDEN

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition HIDDEN
      Checks that element is not visible or does not exists. Opposite to APPEAR
      Sample
      $("input").shouldBe(HIDDEN);
    • APPEAR

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition APPEAR
      Synonym for VISIBLE - may be used for better readability
      Sample
      $("#logoutLink").should(APPEAR);
    • APPEARS

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition APPEARS
      Synonym for VISIBLE - may be used for better readability

      $("#logoutLink").waitUntil(APPEARS, 10000);

    • DISAPPEARS

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition DISAPPEARS
      Synonym for HIDDEN - may be used for better readability:

      Sample: $("#loginLink").waitUntil(DISAPPEARS, 9000);

    • DISAPPEAR

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition DISAPPEAR
      Synonym for HIDDEN - may be used for better readability:

      $("#loginLink").should(DISAPPEAR);

    • READONLY

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition READONLY
      Check if element has "readonly" attribute (with any value)

      Sample: $("input").shouldBe(readonly);

    • FOCUSED

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition FOCUSED
      Check if browser focus is currently on a given element.
    • SELECTED

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition SELECTED
      Checks that element is selected
      See Also:
      • WebElement.isSelected()
    • EMPTY_ELEMENT

      public static final com.workfusion.rpa.helpers.conditionsnative.UiCondition EMPTY_ELEMENT
      1) For input element, checks that value is missing or empty

      Sample: $("#input").shouldBe(EMPTY_ELEMENT)

      2) For other elements, checks that text is empty

      Sample: $("h2").shouldBe(EMPTY_ELEMENT)

  • Method Details

    • hasAttribute

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition hasAttribute(String attributeName, String attributeValue)
      Checks that current element has an attribute with specified value

      Sample: $("#mydiv").waitUntil(hasAttribute("fileId", "12345"), 7000);

      Parameters:
      attributeName - name of attribute
      attributeValue - expected value of attribute
      Returns:
      true if attribute with the specified value exists
    • attribute

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition attribute(String attributeName)
      Checks that element has a given attribute (with any value)

      Sample: $("#mydiv").shouldHave(attribute("fileId"));

      Parameters:
      attributeName - name of attribute, not null
      Returns:
      true if attribute exists
    • attribute

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition attribute(String attributeName, String expectedAttributeValue)
      Checks that current element has an attribute with specified value

      Sample: $("#mydiv").shouldHave(attribute("fileId", "12345"));

      Parameters:
      attributeName - name of attribute
      expectedAttributeValue - expected value of attribute
      Returns:
      true if attribute with the specified value exists
    • partialValue

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition partialValue(String expectedPartOfValue)
      Asserts that element has given "value" attribute as substring

      NB! Ignores difference in non-visible characters like spaces, non-breakable spaces, tabs, newlines etc.

      Sample: $("input").shouldHave(partialValue("12345 666 77"));

      Parameters:
      expectedPartOfValue - expected part of value of "value" attribute
    • hasPartialValue

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition hasPartialValue(String expectedPartOfValue)
      Synonym for partialValue(String)

      NB! Ignores difference in non-visible characters like spaces, non-breakable spaces, tabs, newlines etc.

      Sample: $("#myInput").waitUntil(hasPartialValue("John"), 5000)

      Parameters:
      expectedPartOfValue - expected part of value of "value" attribute
    • value

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition value(String expectedValue)
      Asserts that element has given "value" attribute as substring

      NB! Value must exactly match the string, including characters like spaces, non-breakable spaces, tabs, newlines etc.

      Sample: $("#input").shouldHave(exactValue("John"));

      Parameters:
      expectedValue - expected value of "value" attribute
    • hasValue

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition hasValue(String expectedValue)
      Synonym for value(String)

      Sample: $("#myInput").waitUntil(hasValue("John"), 5000)

      Parameters:
      expectedValue - expected part of value of "value" attribute
    • name

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition name(String name)
      Asserts that element has given "name" attribute as substring

      Sample: $("#input").shouldHave(name("username"))

      Parameters:
      name - expected name of input field
    • type

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition type(String type)
      Asserts that element has given "type" attribute as substring

      Sample: $("#input").shouldHave(type("checkbox"))

      Parameters:
      type - expected type of input field
    • id

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition id(String id)
      Asserts that element has given "id" attribute as substring

      Sample: $("#input").shouldHave(id("myForm"))

      Parameters:
      id - expected id of input field
    • hasText

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition hasText(String text)
      Asserts that element has specified text content

      Sample: $("h1").waitUntil(hasText("Hello"), 10000)

      Case sensitive

      Parameters:
      text - expected text of Ui element
    • text

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition text(String text)
      Asserts that element has specified text content

      Sample: $("h1").shouldHave(text("Hello\s*John"))

      Case sensitive

      Parameters:
      text - expected text of Ui element
    • textCaseInSensitive

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition textCaseInSensitive(String text)
      Asserts that element has specified text content

      Sample: $("h1").shouldHave(textCaseInSensitive("Hello\s*John"))

      Case insensitive

      Parameters:
      text - expected text of HTML element
    • matchRegexp

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition matchRegexp(String regex)
      Assert that given element's text matches given regular expression

      Sample: $("h1").should(matchText("Hello\s*John"))

      Parameters:
      regex - e.g. Kicked.*Chuck Norris - in this case ".*" can contain any characters including spaces, tabs, CR etc.
    • hasClass

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition hasClass(String cssClass)

      Sample: $("input").waitUntil(hasClass("blocked"), 7000);

    • cssClass

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition cssClass(String cssClass)

      Sample: $("input").shouldHave(cssClass("active"));

    • not

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition not(com.workfusion.rpa.helpers.conditionsnative.UiCondition condition)
      Negate given condition. Used for methods like $.shouldNot(exist), $.shouldNotBe(VISIBLE) Typically you don't need to use it.
    • and

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition and(String name, com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
      Check if element matches ALL given conditions.
      Parameters:
      name - Name of this condition, like "empty" (meaning e.g. empty text AND empty value).
      conditions - Conditions to match.
      Returns:
      logical AND for given conditions.
    • or

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition or(String name, com.workfusion.rpa.helpers.conditionsnative.UiCondition... conditions)
      Check if element matches ANY of given conditions.
      Parameters:
      name - Name of this condition, like "error" (meaning e.g. "error" OR "failed").
      conditions - Conditions to match.
      Returns:
      logical OR for given conditions.
    • be

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition be(com.workfusion.rpa.helpers.conditionsnative.UiCondition delegate)
      Used to form human-readable condition expression Example element.should(be(VISIBLE),have(text("abc"))
      Parameters:
      delegate - next condition to wrapp
      Returns:
      Condition
    • have

      public static com.workfusion.rpa.helpers.conditionsnative.UiCondition have(com.workfusion.rpa.helpers.conditionsnative.UiCondition delegate)
      Used to form human-readable condition expression Example element.should(be(VISIBLE),have(text("abc"))
      Parameters:
      delegate - next condition to wrapp
      Returns:
      Condition