Class RPA

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

public class RPA extends Object
This class represents a simplified API for RPA. Static methods and variables from this class and the following classes are automatically included into Machine configs:

The following classes are also automatically imported into Machine configs. They are accessible by their short-class-name (e.g. RemoteWebDriver)


Classes from the following packages also are automatically imported into Machine configs:

  • org.openqa.selenium.*

Main simplified methods:

  • driver() - accessing current driver instance.
  • keyboard() - current driver keyboard.
  • mouse() - current driver mouse.
  • $(By) - finds the first element matching given descriptor.
  • $$(String) - find all elements matching given descriptor.

Also important simplified methods:

  • sendKeys(CharSequence...) - sends a string to current window using keyboard.
  • open(String) - opens a specified URL or application.
  • window(String) - switches to a window with a specified title or descriptor.
  • timeouts(long) - sets the maximum amount of time to wait for condition, page load, script to execute, element search.

The following additional methods are implemented for desktopDriver:

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
     
    static final String
     
    static final String
     
    static final String
     
    static final long
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static UiElement
    $(com.workfusion.rpa.internal.api.element.WebElement webElement)
    Wraps standard Selenium WebElement into UiElement to use additional methods like shouldHave(), selectOption(), etc.
    static UiElement
    $(String cssSelector)
    Finds the first element matching given CSS selector
    static UiElement
    $(String cssSelector, int index)
    Finds the Nth element matching given criteria
    static UiElement
    $(org.openqa.selenium.By seleniumSelector)
    Finds the first element matching given descriptor
    static UiElement
    $(org.openqa.selenium.By seleniumSelector, int index)
    Driver Type: Desktop, Web
    $$(String cssSelector)
    Finds all elements matching given CSS selector.
    $$(Collection<? extends com.workfusion.rpa.internal.api.element.WebElement> elements)
    Initializes collection with Elements
    $$(org.openqa.selenium.By seleniumSelector)
    Find all elements matching given descriptor.
    static com.workfusion.rpa.internal.api.interactions.WFActions
    With this method you can use Selenium Actions like described in the AdvancedUserInteractions page.
    static void
    Desktop: moves back to preview window in desktopDriver history
    static void
    Clean clipboard.
    Returns clipboard implementation based on the settings
    static String
    Returns text from RPA agent clipboard
    static void
    Closes the current window.
    static String
    Accepts (Clicks "Yes" or "Ok") in the existing confirmation dialog (javascript 'alert' or 'confirm').
    static String
    confirm(String expectedDialogText)
    Accepts (Clicks "Yes" or "Ok") in the existing confirmation dialog (javascript 'alert' or 'confirm').
    static String
    Copies all text in PuTTY window.
    static String
    Copies currently selected text and returns it.
    static boolean
    Deletes file or folder on RPA Agent machine
    static void
    Sets an option typeOnScreen is FALSE to a desktop driver
    static String
    Dismisses (clicks "No" or "Cancel") in the existing confirmation dialog (javascript 'alert' or 'confirm').
    static String
    dismiss(String expectedDialogText)
    Dismisses (clicks "No" or "Cancel") in the existing confirmation dialog (javascript 'alert' or 'confirm').
    static byte[]
    Downloads file from RPA Agent machine
    static String
    Downloads a file and saves it on RPA agent machine (in default temp folder)
    static String
    downloadFileOnAgent(String downloadLink, String filePath)
    Downloads a file and saves it on RPA agent machine
    static String
    Downloads text file from RPA Agent machine
    static com.workfusion.rpa.driver.Driver
    Short definition for accessing current driver instance.
    static void
    Sets an option typeOnScreen is TRUE to a desktop driver
    static boolean
    exists(String cssSelector)
    Checks if element exists on the current page.
    static boolean
    exists(org.openqa.selenium.By selector)
    Checks if element exists on the current page.
    static org.openqa.selenium.support.ui.FluentWait<com.workfusion.rpa.internal.api.driver.WebDriver>
    Creates an org.openqa.selenium.support.ui.FluentWait instance with Selenide timeout/polling.
    static void
    Desktop: moves forward to next window in desktopDriver history
    static List<String>
    Deprecated. 
    static List<String>
    getDriverLogs(LogType logType, Level logLevel)
    Deprecated. 
    static UiElement
    getElement(org.openqa.selenium.By criteria)
    Finds the first element matching given criteria
    static UiElement
    getElement(org.openqa.selenium.By criteria, int index)
    Finds the Nth element matching given criteria
    getElements(org.openqa.selenium.By criteria)
    Finds all elements matching given descriptor
    static long
    Returns the frequency with which to check the condition, for example in:
    static long
    Returns the maximum amount of time to wait for a condition, for example in:
    static UiElement
    Returns the currently focused UiElement, that is, the element that will get keystroke events if the user types any.
    static String
    Gets an option related to a desktop driver
    static org.openqa.selenium.WebDriver.Timeouts
    implicitlyWaitTimeout(long milliseconds)
    Sets the maximum amount of time to wait for element search
    static void
    inChrome(groovy.lang.Closure<?> closure)
    Is used for explicitly Chrome driver choosing.
    static void
    inDesktop(groovy.lang.Closure<?> closure)
    Is used for explicitly Desktop driver choosing.
    static void
    inEdge(groovy.lang.Closure<?> closure)
    Is used for explicitly Edge driver choosing.
    static void
    inEdgeInIEMode(groovy.lang.Closure<?> closure)
    Is used for explicitly Edge driver choosing.
    static void
    inFirefox(groovy.lang.Closure<?> closure)
    Is used for explicitly Firefox driver choosing.
    static void
    inIE(groovy.lang.Closure<?> closure)
    Is used for explicitly IE driver choosing.
    static boolean
    Checks if an option related to a desktop driver is enabled
    Short definition for accessing current driver keyboard.
    static void
    Minimizes current window
    Short definition for accessing current driver mouse.
    static Integer
    open(Object target)
    Opens a specified URL or application
    static Integer
    open(String target)
    Opens a specified URL or application
    static void
    open(URL absoluteUrl)
    Opens a specified absolute URL
    static Integer
    openAndFocus(String path2launch, long timeout, long polling)
    Opens a specified URL or application and sets focus
    static void
    Opens a specified URL in Chrome browser
    static void
    openEdge(String target)
    Opens a specified URL in Edge browser
    static void
    Opens a specified URL in Edge browser in IE mode
    static void
    Opens a specified URL in Firefox browser
    static void
    openIE(String target)
    Opens a specified URL in IE browser
    static String
    Opens the link in a new browser's tab.
    static String
    openLinkInNewWindow(org.openqa.selenium.By by)
    Opens the specified link in a new browser's tab.
    static String
    Opens a new browser's tab.
    static org.openqa.selenium.WebDriver.Timeouts
    pageLoadTimeout(long milliseconds)
    Sets the maximum amount of time to wait for page to load
    static void
    Send ALT+F4 to the current window.
    static void
    Send BACK_SPACE to the current window.
    static void
    Send CTRL+A to the current window.
    static void
    Send CTRL+C to the current window.
    static void
    Send CTRL+SHIFT+Z to the current window.
    static void
    Send CTRL+V to the current window.
    static void
    Send CTRL+X to the current window.
    static void
    Send CTRL+Z to the current window.
    static void
    Sends ENTER to the current window.
    static void
    Sends ESCAPE to the current window.
    static void
    Sends SPACE to the current window.
    static void
    Sends TAB to the current window.
    static void
    Refreshes the current page
    Takes a screenshot of the current window
    static org.openqa.selenium.WebDriver.Timeouts
    scriptTimeout(long milliseconds)
    Sets the maximum amount of time to wait for script execution
    static String
    Select all text in current window and copies it to clipboard.
    static void
    sendKeys(CharSequence... charSequences)
    Sends a string to current window using keyboard.
    static void
    Sends a string to current window using keyboard.
    static String
    sendToAgent(byte[] fileData)
    Sends file to RPA Agent default temp folder.
    static String
    sendToAgent(byte[] fileData, String filePath)
    Sends file-data to RPA Agent.
    static String
    sendToAgent(byte[] fileData, String filePrefix, String fileSuffix)
    Sends file-data to RPA Agent, create temporary file
    static String
    sendToAgent(String textContent)
    Sends file to RPA Agent default temp folder.
    static String
    sendToAgent(String textContent, String filePath)
    Sends file-data to RPA Agent.
    static void
    Sets text to RPA agent clipboard
    static void
    setFluentWaitPollingInterval(long fluentWaitPollingInterval)
    Sets The frequency with which to check the condition, for example in:
    static void
    setFluentWaitTimeout(long fluentWaitTimeout)
    Sets the maximum amount of time to wait for a condition, for example in:
    static void
    Sets the Image Matching Options
    static void
    setOption(String key, boolean value)
    Sets an option related to a desktop driver
    static void
    setOption(String key, String value)
    Sets an option related to a desktop driver
    static void
    Sets an option returnType is JSON to a desktop driver
    static void
    Sets an option returnType is STRING to a desktop driver
    static void
    sleep(long milliseconds)
    Wait for a specified number of milliseconds before the next step.
    static com.workfusion.rpa.internal.api.driver.WebDriver
    switchSendRawKeysMode(boolean enable)
    Enables/disables sending keys as is (raw keys mode) or as with handling special keys (CTRL, SHIFT, etc).
    static com.workfusion.rpa.internal.api.driver.WebDriver.TargetLocator
    Switch to window/tab/frame/parentFrame/innerFrame/alert.
    static org.openqa.selenium.WebDriver.Window
    switchToExistingWindow(String titleOrDescriptor)
    Switches to a existing window with a specified title or descriptor Sample switchToExistingWindow("[CLASS:Notepad]")
    static org.openqa.selenium.WebDriver.Window
    switchToExistingWindow(String titleOrDescriptor, Long timeoutInMillis)
    Switches to a existing window with a specified title or descriptor Sample switchToExistingWindow("[CLASS:Notepad]", 100L)
    static String
    Deprecated.
    As of Release 9.1, since window switching algorithm works by default with all opened windows
    static String
    Deprecated.
    As of Release 9.1, since window switching algorithm works by default with all opened windows
    static String
    Deprecated.
    As of Release 9.1, since window switching algorithm works by default with all opened windows
    static String
    Deprecated.
    As of Release 9.1, since window switching algorithm works by default with all opened windows
    static org.openqa.selenium.WebDriver.Timeouts
    Driver Type: Desktop, Web
    static org.openqa.selenium.WebDriver.Timeouts
    timeouts(long milliseconds)
    Sets the maximum amount of time to wait for: condition page load script to execute element search
    static String
    Returns the title of the current page.
    static org.openqa.selenium.support.ui.FluentWait<com.workfusion.rpa.internal.api.driver.WebDriver>
    Deprecated.
    As of Release 9.2, please use fluentWait() instead
    static org.openqa.selenium.WebDriver.Window
    Returns the current window Sample window().fullscreen();
    static org.openqa.selenium.WebDriver.Window
    window(String titleOrDescriptor)
    Switches to a window with a specified title or descriptor Sample window("[CLASS:Notepad]")
    static void
    zoom(double factor)
    Zoom the current page (in or out).

    Methods inherited from class java.lang.Object

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

  • Method Details

    • driver

      public static com.workfusion.rpa.driver.Driver driver()
      Short definition for accessing current driver instance.

      Driver Type: Desktop, Web

      Returns:
      current driver
      See Also:
      • RemoteWebDriver
    • keyboard

      public static RobotsKeyboard keyboard()
      Short definition for accessing current driver keyboard.
      Sample
      keyboard().sendKeys(Keys.TAB);

      Driver Type: Desktop, Web

      Returns:
      current driver keyboard
      See Also:
      • Keyboard
    • mouse

      public static RobotsMouse mouse()
      Short definition for accessing current driver mouse.
      Sample
      mouse().doubleClick(20, 40).contextClick(100, 78);

      Driver Type: Desktop, Web

      Returns:
      current driver mouse
      See Also:
      • Mouse
    • switchTo

      public static com.workfusion.rpa.internal.api.driver.WebDriver.TargetLocator switchTo()

      Switch to window/tab/frame/parentFrame/innerFrame/alert.

      Similar to org.openqa.selenium.WebDriver#switchTo()

      Sample
      switchTo().window("[CLASS:Notepad]").close();

      Driver Type: Desktop, Web

      Returns:
      WebDriver.TargetLocator
    • window

      public static org.openqa.selenium.WebDriver.Window window()
      Returns the current window
      Sample
      window().fullscreen();

      Driver Type: Desktop, Web

      Returns:
      interface for managing the current window
      See Also:
      • WebDriver.Window
    • minimizeWindow

      public static void minimizeWindow()
      Minimizes current window

      Driver Type: Desktop, Web

    • switchToExistingWindow

      public static org.openqa.selenium.WebDriver.Window switchToExistingWindow(String titleOrDescriptor, Long timeoutInMillis)
      Switches to a existing window with a specified title or descriptor
      Sample
      switchToExistingWindow("[CLASS:Notepad]", 100L)

      Driver Type: Desktop

      Parameters:
      titleOrDescriptor - string representation of a window title or descriptor
      timeoutInMillis - timeout in milliseconds for find last open window
      Returns:
      current window
    • switchToExistingWindow

      public static org.openqa.selenium.WebDriver.Window switchToExistingWindow(String titleOrDescriptor)
      Switches to a existing window with a specified title or descriptor
      Sample
      switchToExistingWindow("[CLASS:Notepad]")

      Driver Type: Desktop

      Parameters:
      titleOrDescriptor - string representation of a window title or descriptor
      Returns:
      current window
    • window

      public static org.openqa.selenium.WebDriver.Window window(String titleOrDescriptor)
      Switches to a window with a specified title or descriptor
      Sample
      window("[CLASS:Notepad]")

      Driver Type: Desktop, Web

      Parameters:
      titleOrDescriptor - string representation of a window title or descriptor
      Returns:
      current window
    • sendKeys

      public static void sendKeys(Object text)

      Sends a string to current window using keyboard.

      Delegates invocation to driver.getKeyboard().sendKeys(...)

      Driver Type: Desktop, Web

      Parameters:
      text - can be a Collection or Array, all items will be concatenated
    • sendKeys

      public static void sendKeys(CharSequence... charSequences)

      Sends a string to current window using keyboard.

      Delegates invocation to driver.getKeyboard().sendKeys(...)

      Driver Type: Desktop, Web

      Parameters:
      charSequences - can be a Char Sequence (ex. String, Keys.CHAR), all items will be concatenated
    • pressEnter

      public static void pressEnter()
      Sends ENTER to the current window.
       pressEnter();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.ENTER)

      Driver Type: Desktop, Web

    • pressTab

      public static void pressTab()
      Sends TAB to the current window.
       pressTab();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.TAB)

      Driver Type: Desktop, Web

    • pressEscape

      public static void pressEscape()
      Sends ESCAPE to the current window.
       pressEscape();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.ESCAPE)

      Driver Type: Desktop, Web

    • pressSpace

      public static void pressSpace()
      Sends SPACE to the current window.
       pressSpace();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.SPACE)

      Driver Type: Desktop, Web

    • pressBackSpace

      public static void pressBackSpace()
      Send BACK_SPACE to the current window.
       pressBackSpace();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.BACK_SPACE)

      Driver Type: Desktop, Web

    • pressCtrlA

      public static void pressCtrlA()
      Send CTRL+A to the current window.
       pressCtrlA();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.chord(Keys.CONTROL, "a"))

      Driver Type: Desktop, Web

    • pressCtrlC

      public static void pressCtrlC()
      Send CTRL+C to the current window.
       pressCtrlC();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.chord(Keys.CONTROL, "c"))

      Driver Type: Desktop, Web

    • pressCtrlV

      public static void pressCtrlV()
      Send CTRL+V to the current window.
       pressCtrlV();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.chord(Keys.CONTROL, "v"))

      Driver Type: Desktop, Web

    • pressCtrlX

      public static void pressCtrlX()
      Send CTRL+X to the current window.
       pressCtrlX();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.chord(Keys.CONTROL, "x"))

      Driver Type: Desktop, Web

    • pressCtrlZ

      public static void pressCtrlZ()
      Send CTRL+Z to the current window.
       pressCtrlZ();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.chord(Keys.CONTROL, "z"))

      Driver Type: Desktop, Web

    • pressCtrlShiftZ

      public static void pressCtrlShiftZ()
      Send CTRL+SHIFT+Z to the current window.
       pressCtrlShiftZ();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.chord(Keys.CONTROL, Keys.SHIFT, "z"))

      Driver Type: Desktop, Web

    • pressAltF4

      public static void pressAltF4()
      Send ALT+F4 to the current window.
       pressAltF4();

      Implementation details: This is the same as

       driver().getKeyboard().sendKeys(Keys.chord(Keys.ALT, Keys.F4))

      Driver Type: Desktop, Web

    • openAndFocus

      public static Integer openAndFocus(String path2launch, long timeout, long polling)
      Opens a specified URL or application and sets focus
       Object calculator = "calc.exe";
       openAndFocus(calculator, 1000, 250);

      Driver Type: Desktop

      Parameters:
      path2launch - Application path
      timeout - Timeout during driver try get focus in milliseconds
      polling - Polling interval in milliseconds
      Returns:
      Process ID
      Since:
      9.2.0 should return ID of started process for Desktop driver or return NULL for Web drivers
    • open

      public static Integer open(Object target)
      Opens a specified URL or application
       Object calculator = "calc.exe";
       open(calculator);

      Driver Type: Desktop, Web

      Parameters:
      target - object that will be converted to String
      Returns:
      Process ID
      Since:
      9.2.0 should return ID of started process for Desktop driver or return NULL for Web drivers
    • open

      public static Integer open(String target)
      Opens a specified URL or application
       open("calc.exe");

      Driver Type: Desktop, Web

      Parameters:
      target - String with URL or application path
      Returns:
      Process ID
      Since:
      9.2.0 should return ID of started process for Desktop driver or return NULL for Web drivers
    • openFirefox

      public static void openFirefox(String target)
      Opens a specified URL in Firefox browser
       open("https://workfusion.com");

      Driver Type: Universal

      Parameters:
      target - String with URL
    • inFirefox

      public static void inFirefox(groovy.lang.Closure<?> closure)
      Is used for explicitly Firefox driver choosing. In case when driver auto detection is ambiguous.
           inFirefox() {
               open("https://workfusion.com")
           }
       
      Such constructions are not supported e.g
        inFirefox{
            inChrome() {
                open("https://workfusion.com")
            }
        }
       

      Driver Type: Universal

      Parameters:
      closure - code that will be executed using Firefox driver
      Since:
      8.5.0.2
    • openIE

      public static void openIE(String target)
      Opens a specified URL in IE browser
       open("https://workfusion.com");

      Driver Type: Universal

      Parameters:
      target - String with URL
    • inIE

      public static void inIE(groovy.lang.Closure<?> closure)
      Is used for explicitly IE driver choosing. In case when driver auto detection is ambiguous.
           inIE() {
               open("https://workfusion.com")
           }
       
      Such constructions are not supported e.g
        inIE{
            inChrome() {
                open("https://workfusion.com")
            }
        }
       

      Driver Type: Universal

      Parameters:
      closure - code that will be executed using IE driver
      Since:
      8.5.0.2
    • openChrome

      public static void openChrome(String target)
      Opens a specified URL in Chrome browser
       open("https://workfusion.com");

      Driver Type: Universal

      Parameters:
      target - String with URL
    • openEdge

      public static void openEdge(String target)
      Opens a specified URL in Edge browser
       open("https://workfusion.com");

      Driver Type: Universal

      Parameters:
      target - String with URL
    • openEdgeInIEMode

      public static void openEdgeInIEMode(String target)
      Opens a specified URL in Edge browser in IE mode
       open("https://workfusion.com");

      Driver Type: Universal

      Parameters:
      target - String with URL
    • inChrome

      public static void inChrome(groovy.lang.Closure<?> closure)
      Is used for explicitly Chrome driver choosing. In case when driver auto detection is ambiguous.
           inChrome() {
               open("https://workfusion.com")
           }
       
      Such constructions are not supported e.g
        inChrome{
            inDesktop() {
                open("https://workfusion.com")
            }
        }
       

      Driver Type: Universal

      Parameters:
      closure - code that will be executed using Chrome driver
      Since:
      8.5.0.2
    • inDesktop

      public static void inDesktop(groovy.lang.Closure<?> closure)
      Is used for explicitly Desktop driver choosing. In case when driver auto detection is ambiguous.
           inDesktop() {
               open("https://workfusion.com")
           }
       
      Such constructions are not supported e.g
        inDesktop{
            inChrome() {
                open("https://workfusion.com")
            }
        }
       

      Driver Type: Universal

      Parameters:
      closure - code that will be executed using Desktop driver
      Since:
      8.5.0.2
    • inEdge

      public static void inEdge(groovy.lang.Closure<?> closure)
      Is used for explicitly Edge driver choosing. In case when driver auto detection is ambiguous.
           inEdge() {
               open("https://workfusion.com")
           }
       
      Such constructions are not supported e.g
        inEdge{
            inChrome() {
                open("https://workfusion.com")
            }
        }
       

      Driver Type: Universal

      Parameters:
      closure - code that will be executed using Edge driver
    • inEdgeInIEMode

      public static void inEdgeInIEMode(groovy.lang.Closure<?> closure)
      Is used for explicitly Edge driver choosing. In case when driver auto detection is ambiguous.
           inEdgeInIEMode() {
               open("https://workfusion.com")
           }
       
      Such constructions are not supported e.g
        inEdgeInIEMode{
            inChrome() {
                open("https://workfusion.com")
            }
        }
       

      Driver Type: Universal

      Parameters:
      closure - code that will be executed using Edge driver
    • open

      public static void open(URL absoluteUrl)
      Opens a specified absolute URL
       open(new URL("https://workfusion.com"));

      Driver Type: Web

      Parameters:
      absoluteUrl - String with absolute URL
    • close

      public static void close()

      Closes the current window.

      This is the same as:

       driver.close();
       

      Driver Type: Desktop, Web

    • refresh

      public static void refresh()

      Refreshes the current page

      This is the same as:

       driver.navigate().refresh();
       

      Driver Type: Web

    • back

      public static void back()

      Desktop: moves back to preview window in desktopDriver history

      Web: moves back a single item in the browser's history.

      Driver Type: Desktop, Web

      This is the same as:

       driver.navigate().back();
       
    • forward

      public static void forward()

      Desktop: moves forward to next window in desktopDriver history

      Web: moves a single item forward in the browser's history.

      Driver Type: Desktop, Web

      This is the same as:

       driver.navigate().forward();
       
    • title

      public static String title()

      Returns the title of the current page.

      This is the same as:

       driver.title();
       

      Driver Type: Desktop, Web

    • sleep

      public static void sleep(long milliseconds)

      Wait for a specified number of milliseconds before the next step.

      This is the same as:

       Thread.sleep(milliseconds);
       

      Driver Type: Desktop, Web

      Parameters:
      milliseconds - time to sleep in milliseconds
    • $

      public static UiElement $(com.workfusion.rpa.internal.api.element.WebElement webElement)
      Wraps standard Selenium WebElement into UiElement to use additional methods like shouldHave(), selectOption(), etc.

      Driver Type: Desktop, Web

      Parameters:
      webElement - standard Selenium WebElement
      Returns:
      given WebElement wrapped into UiElement
      See Also:
    • exists

      public static boolean exists(String cssSelector)
      Checks if element exists on the current page.

      Driver Type: Desktop, Web

      Parameters:
      cssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"
      Returns:
      false if element is not found
      Since:
      9.2
    • exists

      public static boolean exists(org.openqa.selenium.By selector)
      Checks if element exists on the current page.

      Driver Type: Desktop, Web

      Parameters:
      selector - any selector like:
      By.id(), By.name(), By.cssSelector("[CLASS:Edit; INSTANCE:1]")
      Returns:
      false if element is not found
      Since:
      9.2
    • $

      public static UiElement $(String cssSelector)
      Finds the first element matching given CSS selector

      Driver Type: Desktop, Web

      Parameters:
      cssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"
      Returns:
      UiElement
    • $

      public static UiElement $(org.openqa.selenium.By seleniumSelector)
      Finds the first element matching given descriptor

      Driver Type: Desktop, Web

      Parameters:
      seleniumSelector - any selector like:
      By.id(), By.name(), By.cssSelector("[CLASS:Edit; INSTANCE:1]")
      Returns:
      UiElement
    • $

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

      Driver Type: Desktop, Web

      See Also:
    • $

      public static UiElement $(String cssSelector, int index)
      Finds the Nth element matching given criteria

      Driver Type: Desktop, Web

      Parameters:
      cssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"
      index - 0..N
      Returns:
      UiElement
    • $$

      public static UiElementCollection $$(Collection<? extends com.workfusion.rpa.internal.api.element.WebElement> elements)
      Initializes collection with Elements

      Driver Type: Desktop, Web

      Parameters:
      elements - Collection of standard Selenium WebElements
      Returns:
      a collection of UIElements
      See Also:
    • $$

      public static UiElementCollection $$(String cssSelector)
      Finds all elements matching given CSS selector. Method returns a UiElementCollection which is a list of WebElement objects that can be iterated, and at the same time is an implementation of WebElement interface, meaning that you can call methods .sendKeys(), click() etc. on it.

      Driver Type: Desktop, Web

      Parameters:
      cssSelector - any CSS selector like "input[name='first_name']" or "#messages .new_message"
      Returns:
      a collection of UIElements OR an empty list if no elements were found
      See Also:
    • $$

      public static UiElementCollection $$(org.openqa.selenium.By seleniumSelector)
      Find all elements matching given descriptor. Method returns a UiElementCollection which is a list of WebElement objects that can be iterated, and at the same time is an implementation of WebElement interface, meaning that you can call methods .sendKeys(), click() etc. on it.

      Driver Type: Desktop, Web

      Parameters:
      seleniumSelector - any selector like:
      By.id(), By.name(), By.cssSelector("[CLASS:Edit; INSTANCE:1]")
      Returns:
      empty list if element was no found
      See Also:
    • getElement

      public static UiElement getElement(org.openqa.selenium.By criteria)
      Finds the first element matching given criteria

      Driver Type: Desktop, Web

      Parameters:
      criteria - instance of By: By.id(), By.className() etc.
      Returns:
      UiElement
    • getElement

      public static UiElement getElement(org.openqa.selenium.By criteria, int index)
      Finds the Nth element matching given criteria

      Driver Type: Desktop, Web

      Parameters:
      criteria - instance of By: By.id(), By.className() etc.
      index - 0..N
      Returns:
      UiElement
      Throws:
      IndexOutOfBoundsException - if the specified index does not exist
    • getElements

      public static UiElementCollection getElements(org.openqa.selenium.By criteria)
      Finds all elements matching given descriptor

      Driver Type: Desktop, Web

      Parameters:
      criteria - instance of By: By.id(), By.className() etc.
      Returns:
      empty list if element was no found
    • confirm

      public static String confirm()
      Accepts (Clicks "Yes" or "Ok") in the existing confirmation dialog (javascript 'alert' or 'confirm').

      Driver Type: Web

      Returns:
      actual dialog text
      Throws:
      org.openqa.selenium.TimeoutException - if dialog is not shown
    • confirm

      public static String confirm(String expectedDialogText)
      Accepts (Clicks "Yes" or "Ok") in the existing confirmation dialog (javascript 'alert' or 'confirm').

      Driver Type: Web

      Parameters:
      expectedDialogText - if not null, checks that confirmation dialog displays this message (case-sensitive)
      Returns:
      actual dialog text
      Throws:
      IllegalStateException - if confirmation message differs from expected message
      org.openqa.selenium.TimeoutException - if dialog is not shown
    • dismiss

      public static String dismiss()
      Dismisses (clicks "No" or "Cancel") in the existing confirmation dialog (javascript 'alert' or 'confirm').

      Driver Type: Web

      Returns:
      actual dialog text
      Throws:
      org.openqa.selenium.TimeoutException - if dialog is not shown
    • dismiss

      public static String dismiss(String expectedDialogText)
      Dismisses (clicks "No" or "Cancel") in the existing confirmation dialog (javascript 'alert' or 'confirm').

      Driver Type: Web

      Parameters:
      expectedDialogText - if not null, checks that confirmation dialog displays this message (case-sensitive)
      Returns:
      actual dialog text
      Throws:
      IllegalStateException - if confirmation message differs from expected message
      org.openqa.selenium.TimeoutException - if dialog is not shown
    • getFocusedElement

      public static UiElement getFocusedElement()
      Returns the currently focused UiElement, that is, the element that will get keystroke events if the user types any.

      Driver Type: Web

      Sample
      getFocusedElement().sendKeys(Keys.ENTER);
      Returns:
      UiElement which has focus
    • Wait

      @Deprecated public static org.openqa.selenium.support.ui.FluentWait<com.workfusion.rpa.internal.api.driver.WebDriver> Wait()
      Deprecated.

      As of Release 9.2, please use fluentWait() instead

      Creates an org.openqa.selenium.support.ui.FluentWait instance with Selenide timeout/polling.
      Sample
      Wait().until(invisibilityOfElementLocated(By.id("magic-id")));

      Driver Type: Desktop, Web

      Returns:
      instance of org.openqa.selenium.support.ui.FluentWait
      See Also:
    • fluentWait

      public static org.openqa.selenium.support.ui.FluentWait<com.workfusion.rpa.internal.api.driver.WebDriver> fluentWait()
      Creates an org.openqa.selenium.support.ui.FluentWait instance with Selenide timeout/polling.
      Sample
      fluentWait().until(invisibilityOfElementLocated(By.id("magic-id")));

      Driver Type: Desktop, Web

      Returns:
      instance of org.openqa.selenium.support.ui.FluentWait
      See Also:
    • actions

      public static com.workfusion.rpa.internal.api.interactions.WFActions actions()
      With this method you can use Selenium Actions like described in the AdvancedUserInteractions page.
         actions()
          .sendKeys($(By.name("rememberMe")), "John")
          .click($(#rememberMe"))
          .click($(byText("Login")))
          .build()
          .perform();
       

      Driver Type: Desktop, Web

    • zoom

      public static void zoom(double factor)
      Zoom the current page (in or out).

      Driver Type: Web

      Parameters:
      factor - e.g. 1.1 or 2.0 or 0.5
    • getDriverLogs

      @Deprecated public static List<String> getDriverLogs(LogType logType)
      Deprecated.

      Driver Type: Web

      See Also:
    • getDriverLogs

      @Deprecated public static List<String> getDriverLogs(LogType logType, Level logLevel)
      Deprecated.
      Getting and filtering of the WebDriver logs for specified LogType by specified logging level
      For example to get WebDriver Browser's console output (including JS info, warnings, errors, etc. messages) you can use:
       
       for(String logEntry : getDriverLogs(LogType.BROWSER, Level.ALL)) {
                Reporter.log(logEntry + "<br>");
              }
         
      Note that currently "manage().logs()" is in the Beta stage.

      Driver Type: Web

      Parameters:
      logType - WebDriver supported log types see
      logLevel - logging level that will be used to control logging output
      Returns:
      list of log entries
      See Also:
    • switchToRootWindow

      @Deprecated public static String switchToRootWindow()
      Deprecated.

      As of Release 9.1, since window switching algorithm works by default with all opened windows

      Switching focus to the first opened window
      Returns:
      window's handler, which is in focus now
    • switchToLastWindow

      @Deprecated public static String switchToLastWindow()
      Deprecated.

      As of Release 9.1, since window switching algorithm works by default with all opened windows

      Switching focus to the last opened window
      Returns:
      window's handler, which is in focus now
    • switchToPrevWindow

      @Deprecated public static String switchToPrevWindow()
      Deprecated.

      As of Release 9.1, since window switching algorithm works by default with all opened windows

      Switching focus to the previously opened window before current window
      Returns:
      window's handler, which is in focus now
    • switchToNextWindow

      @Deprecated public static String switchToNextWindow()
      Deprecated.

      As of Release 9.1, since window switching algorithm works by default with all opened windows

      Switching focus to the next opened window after current window
      Returns:
      window's handler, which is in focus now
    • openNewWindow

      public static String openNewWindow()
      Opens a new browser's tab. Focus will be switched to the new opened window.

      Driver Type: Web

      Returns:
      handler of the new window
    • openLinkInNewWindow

      public static String openLinkInNewWindow(String url)
      Opens the link in a new browser's tab. Focus will be switched to the new opened window.

      Driver Type: Web

      Returns:
      handler of the new window
    • openLinkInNewWindow

      public static String openLinkInNewWindow(org.openqa.selenium.By by)
      Opens the specified link in a new browser's tab. Focus will stay on the current window, which was targeted before click.

      Driver Type: Web

      Sample
      openLinkInNewWindow(byCssSelector(".container a.create-new")).switchTo();
      Parameters:
      by - - link descriptor
      Returns:
      handler of the new window
    • getFluentWaitTimeout

      public static long getFluentWaitTimeout()
      Returns the maximum amount of time to wait for a condition, for example in:
       Wait().until(<some_condition>);
       $(".demo-el").waitUntil(<other_condition>);
       

      Driver Type: Desktop, Web

      Returns:
      timeout in milliseconds
    • setFluentWaitTimeout

      public static void setFluentWaitTimeout(long fluentWaitTimeout)
      Sets the maximum amount of time to wait for a condition, for example in:
       Wait().until(<some_condition>);
       $(".demo-el").waitUntil(<other_condition>);
       

      Driver Type: Desktop, Web

      Parameters:
      fluentWaitTimeout - timeout in milliseconds
    • getFluentWaitPollingInterval

      public static long getFluentWaitPollingInterval()
      Returns the frequency with which to check the condition, for example in:
       Wait().until(<some_condition>);
       $(".demo-el").waitUntil(<other_condition>);
       

      Driver Type: Desktop, Web

      Returns:
      frequency in milliseconds
    • setFluentWaitPollingInterval

      public static void setFluentWaitPollingInterval(long fluentWaitPollingInterval)
      Sets The frequency with which to check the condition, for example in:
       Wait().until(<some_condition>);
       $(".demo-el").waitUntil(<other_condition>);
       

      Driver Type: Desktop, Web

      Parameters:
      fluentWaitPollingInterval - frequency in milliseconds
    • timeouts

      public static org.openqa.selenium.WebDriver.Timeouts timeouts()

      Driver Type: Desktop, Web

      Returns:
      the interface for managing driver timeouts.
    • timeouts

      public static org.openqa.selenium.WebDriver.Timeouts timeouts(long milliseconds)
      Sets the maximum amount of time to wait for:
      • condition
      • page load
      • script to execute
      • element search

      Driver Type: Desktop, Web

      Parameters:
      milliseconds - timeout in milliseconds
      Returns:
      an Object for managing Timeouts
      See Also:
    • implicitlyWaitTimeout

      public static org.openqa.selenium.WebDriver.Timeouts implicitlyWaitTimeout(long milliseconds)
      Sets the maximum amount of time to wait for element search

      Driver Type: Desktop, Web

      Parameters:
      milliseconds - timeout in milliseconds
      Returns:
      an Object for managing Timeouts
      See Also:
      • WebDriver.Timeouts.implicitlyWait(Duration)
    • pageLoadTimeout

      public static org.openqa.selenium.WebDriver.Timeouts pageLoadTimeout(long milliseconds)
      Sets the maximum amount of time to wait for page to load

      Driver Type: Desktop, Web

      Parameters:
      milliseconds - timeout in milliseconds
      Returns:
      an Object for managing Timeouts
      See Also:
      • WebDriver.Timeouts.pageLoadTimeout(Duration)
    • scriptTimeout

      public static org.openqa.selenium.WebDriver.Timeouts scriptTimeout(long milliseconds)
      Sets the maximum amount of time to wait for script execution

      Driver Type: Desktop, Web

      Parameters:
      milliseconds - timeout in milliseconds
      Returns:
      an Object for managing Timeouts
      See Also:
      • WebDriver.Timeouts.scriptTimeout(Duration)
    • setImageMatchingOptions

      public static void setImageMatchingOptions(Map<String,Object> options)
      Sets the Image Matching Options

      Driver Type: Desktop/p>

      Parameters:
      options - key-values options
    • screenshotAsImage

      public static BufferedImage screenshotAsImage()
      Takes a screenshot of the current window

      Driver Type: Web

      Returns:
      instance of BufferedImage object
    • clipboard

      public static RobotClipboard clipboard()
      Returns clipboard implementation based on the settings

      Driver Type: Desktop

      Returns:
      clipboard implementation
    • cleanClipboard

      public static void cleanClipboard()
      Clean clipboard. Send empty string to clipboard.

      Driver Type: Desktop

      Since:
      9.2
      See Also:
    • clipboardText

      public static String clipboardText()
      Returns text from RPA agent clipboard

      Driver Type: Desktop

      Returns:
      text from clipboard
    • copySelectedText

      public static String copySelectedText()
      Copies currently selected text and returns it.

      Driver Type: Desktop

      Returns:
      text from clipboard
    • selectAllTextAndCopy

      public static String selectAllTextAndCopy()
      Select all text in current window and copies it to clipboard.
      The same as (CTRL + A; CTRL + C)

      Driver Type: Desktop

      Returns:
      text from clipboard
    • setClipboardText

      public static void setClipboardText(String text)
      Sets text to RPA agent clipboard

      Driver Type: Desktop

      Parameters:
      text - text to set in clipboard
    • copyPuttyWindowText

      public static String copyPuttyWindowText()
      Copies all text in PuTTY window. Fully supported for PuTTY starting from v.0.67
      Sample
      window("[CLASS:PuTTY]");
      sendKeys("vim 123.txt", Keys.ENTER);
      copyPuttyWindowText();

      Driver Type: Desktop

      specially implemented for PuTTY, fully supported for PuTTY starting from v.0.67

      Returns:
      text from PuTTY window
    • sendToAgent

      public static String sendToAgent(String textContent) throws IOException
      Sends file to RPA Agent default temp folder. If file already exists, it will be rewritten

      Driver Type: Desktop

      Parameters:
      textContent - file text content
      Returns:
      absolute path to file
      Throws:
      IOException
    • sendToAgent

      public static String sendToAgent(byte[] fileData) throws IOException
      Sends file to RPA Agent default temp folder. If file already exists, it will be rewritten

      Driver Type: Desktop

      Parameters:
      fileData - byte array
      Returns:
      absolute path to file
      Throws:
      IOException
    • sendToAgent

      public static String sendToAgent(String textContent, String filePath) throws IOException
      Sends file-data to RPA Agent. If file already exists, it will be rewritten

      Driver Type: Desktop

      Parameters:
      textContent - file text content
      filePath - path to save the file
      Returns:
      absolute path to file
      Throws:
      IOException
    • sendToAgent

      public static String sendToAgent(byte[] fileData, String filePath) throws IOException
      Sends file-data to RPA Agent. If file already exists, it will be rewritten

      Driver Type: Desktop

      Parameters:
      fileData - byte array
      filePath - path to save the file
      Returns:
      absolute path to file
      Throws:
      IOException
    • sendToAgent

      public static String sendToAgent(byte[] fileData, String filePrefix, String fileSuffix) throws IOException
      Sends file-data to RPA Agent, create temporary file

      Driver Type: Desktop

      Parameters:
      fileData - byte array
      filePrefix - prefix for file name
      fileSuffix - postfix for file name. Can be extension if starts from dot (.txt)
      Returns:
      path to temp file
      Throws:
      IOException
    • downloadFileFromAgent

      public static byte[] downloadFileFromAgent(String filePath) throws IOException
      Downloads file from RPA Agent machine

      Note: this method is intended for simple cases where it is convenient to read all bytes into a byte array. It is not intended for reading large files.

      Driver Type: Desktop

      Parameters:
      filePath - specifies path to the file that will be downloaded
      Returns:
      content as byte[]
      Throws:
      OutOfMemoryError - if an array of the required size cannot be allocated, for example the file is larger that 2GB
      IOException
    • downloadTextFileFromAgent

      public static String downloadTextFileFromAgent(String filePath) throws IOException
      Downloads text file from RPA Agent machine

      Driver Type: Desktop

      Parameters:
      filePath - specifies path to the file that will be downloaded
      Returns:
      content as String
      Throws:
      IOException
      See Also:
    • deleteFileOnAgent

      public static boolean deleteFileOnAgent(String filePath)
      Deletes file or folder on RPA Agent machine

      Driver Type: Desktop

      Parameters:
      filePath - specifies path to the file or folder that will be deleted
      Returns:
      boolean: was file/folder deleted or not
    • downloadFileOnAgent

      public static String downloadFileOnAgent(String downloadLink) throws IOException
      Downloads a file and saves it on RPA agent machine (in default temp folder)

      Driver Type: Desktop

      Parameters:
      downloadLink - link to download the file
      Returns:
      path to downloaded file
      Throws:
      IOException
    • downloadFileOnAgent

      public static String downloadFileOnAgent(String downloadLink, String filePath) throws IOException
      Downloads a file and saves it on RPA agent machine

      Driver Type: Desktop

      Parameters:
      downloadLink - link to download the file
      filePath - specifies folder to save file
      Returns:
      path to downloaded file
      Throws:
      IOException
    • switchSendRawKeysMode

      public static com.workfusion.rpa.internal.api.driver.WebDriver switchSendRawKeysMode(boolean enable)
      Enables/disables sending keys as is (raw keys mode) or as with handling special keys (CTRL, SHIFT, etc). Helpful for sending text as is, which contains special text, ex. passwords.

      Driver Type: Desktop

      Parameters:
      enable - - true - send as raw keys; false - send as special keys;
      Returns:
      current driver
    • setOption

      public static void setOption(String key, String value)
      Sets an option related to a desktop driver

      Driver Type: Desktop

      Parameters:
      key - option key
      value - option string value
    • setOption

      public static void setOption(String key, boolean value)
      Sets an option related to a desktop driver

      Driver Type: Desktop

      Parameters:
      key - option key
      value - option boolean value
    • isOptionEnabled

      public static boolean isOptionEnabled(String key)
      Checks if an option related to a desktop driver is enabled

      Driver Type: Desktop

      Parameters:
      key - option key
      Returns:
      true if option is enabled, false otherwise
    • getOption

      public static String getOption(String key)
      Gets an option related to a desktop driver

      Driver Type: Desktop

      Parameters:
      key - option key
      Returns:
      option's value if it exists, null otherwise
    • enableTypeOnScreen

      public static void enableTypeOnScreen()
      Sets an option typeOnScreen is TRUE to a desktop driver

      Driver Type: Desktop

      Enabling this option makes your automation less stable in case some popup windows appear.

    • disableTypeOnScreen

      public static void disableTypeOnScreen()
      Sets an option typeOnScreen is FALSE to a desktop driver

      Driver Type: Desktop

    • setReturnTypeAsJSON

      public static void setReturnTypeAsJSON()
      Sets an option returnType is JSON to a desktop driver

      Driver Type: Desktop

    • setReturnTypeAsString

      public static void setReturnTypeAsString()
      Sets an option returnType is STRING to a desktop driver

      Driver Type: Desktop