Class UiSelectors

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

public class UiSelectors extends Object
This class adds static methods for quick simplified creation of RPA selectors.
Samples
$(withText("Create Invoice")).shouldBe(visible, enabled);
$$(byTagName("A")).shouldHaveSize(5);
$(byXpath("//html/body/div[5]")).doubleClick();
  • Method Summary

    Modifier and Type
    Method
    Description
    static org.openqa.selenium.By
    by(String attributeName, String attributeValue)
    Synonym for #byAttribute Seems to work incorrectly in HtmlUnit and PhantomJS if attribute name contains dash (e.g.
    static org.openqa.selenium.By
    byAttribute(String attributeName, String attributeValue)
    Find elements having attribute with given value.
    static org.openqa.selenium.By
    byClassName(String className)
     
    static org.openqa.selenium.By
     
    static org.openqa.selenium.By
     
    static org.openqa.selenium.By
    byImage(String imageUrl)
    Finds the first image element matching given URL.
    static org.openqa.selenium.By
    byImage(String imageUrl, int offsetX, int offsetY)
    Finds the first image element matching given URL.
    static org.openqa.selenium.By
    byLinkText(String linkText)
     
    static org.openqa.selenium.By
    byName(String name)
     
    static org.openqa.selenium.By
    byPartialLinkText(String partialLinkText)
     
    static org.openqa.selenium.By
     
    static org.openqa.selenium.By
    byText(String elementText)
    Find element that has EXACTLY this text NB!
    static org.openqa.selenium.By
    byTitle(String title)
    Find element with given title ("title" attribute)
    static org.openqa.selenium.By
    byValue(String value)
    Find input element with given value ("value" attribute)
    static org.openqa.selenium.By
    byXpath(String xpath)
     
    static org.openqa.selenium.By
    withText(String elementText)
    Find element CONTAINING given text (as a substring) NB!

    Methods inherited from class java.lang.Object

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

    • withText

      public static org.openqa.selenium.By withText(String elementText)
      Find element CONTAINING given text (as a substring) NB! It seems that Selenium WebDriver does not support i18n characters in XPath :(
      Parameters:
      elementText - Text to search inside element
      Returns:
      standard selenium By criteria`
    • byText

      public static org.openqa.selenium.By byText(String elementText)
      Find element that has EXACTLY this text NB! It seems that Selenium WebDriver does not support i18n characters in XPath :(
      Parameters:
      elementText - Text that searched element should have
      Returns:
      standard selenium By criteria
    • byImage

      public static org.openqa.selenium.By byImage(String imageUrl)
      Finds the first image element matching given URL. All the actions that rely on image location will use image center coordinates.
      Parameters:
      imageUrl - image URL
      Returns:
      image-based criteria
    • byImage

      public static org.openqa.selenium.By byImage(String imageUrl, int offsetX, int offsetY)
      Finds the first image element matching given URL. All the actions that rely on image location will be corrected according to provided offsets. Offsets are calculated from the center of the image.
      Parameters:
      imageUrl - image URL
      offsetX - horizontal offset from the center of the image
      offsetY - vertical offset from the center of the image
      Returns:
      image-based criteria
    • byAttribute

      public static org.openqa.selenium.By byAttribute(String attributeName, String attributeValue)
      Find elements having attribute with given value. Seems to work incorrectly if attribute name contains dash, for example: <option data-mailServerId="123"></option>
      Parameters:
      attributeName - name of attribute, should not be empty or null
      attributeValue - value of attribute, should not contain both apostrophes and quotes
      Returns:
      standard selenium By criteria
    • by

      public static org.openqa.selenium.By by(String attributeName, String attributeValue)
      Synonym for #byAttribute Seems to work incorrectly in HtmlUnit and PhantomJS if attribute name contains dash (e.g. "data-mailServerId")
    • byTitle

      public static org.openqa.selenium.By byTitle(String title)
      Find element with given title ("title" attribute)
    • byValue

      public static org.openqa.selenium.By byValue(String value)
      Find input element with given value ("value" attribute)
    • byName

      public static org.openqa.selenium.By byName(String name)
      See Also:
      • By.name(java.lang.String)
    • byTagName

      public static org.openqa.selenium.By byTagName(String name)
      See Also:
      • By.tagName(java.lang.String)
    • byXpath

      public static org.openqa.selenium.By byXpath(String xpath)
      See Also:
      • By.xpath(java.lang.String)
    • byLinkText

      public static org.openqa.selenium.By byLinkText(String linkText)
      See Also:
      • By.linkText(java.lang.String)
    • byPartialLinkText

      public static org.openqa.selenium.By byPartialLinkText(String partialLinkText)
      See Also:
      • By.partialLinkText(java.lang.String)
    • byId

      public static org.openqa.selenium.By byId(String id)
      See Also:
      • By.id(java.lang.String)
    • byCssSelector

      public static org.openqa.selenium.By byCssSelector(String css)
      See Also:
      • By.cssSelector(java.lang.String)
    • byClassName

      public static org.openqa.selenium.By byClassName(String className)
      See Also:
      • By.className(java.lang.String)