Browser Module

The Browser module empowers a robotic process to open and interact with web browsers. Through this module, you can navigate to a URL and interact with the web page just as a human would: click on the page controls, select options, enter values in text fields, retrieve HTML items, and more.

This page describes how to integrate browser methods into your robotic process. Appian RPA's low-code Browser module provides an easier and more robust development experience. For more experienced developers, this page also discusses the options available using the Java module.

To make robotic process development even faster, you can use Selenium IDE to record browser actions and import the file as a section in Appian RPA.

Using the Browser low-code module

The Browser low-code module lets you configure how the robotic process opens and interacts with a web browser. The low-code module simplifies this step in robotic process development by bringing these methods to the Actions dialog and presenting the available options, rather than requiring you to code it using Java.

While these methods can be called using methods in the Java code, using the methods from the robotic process workflow is both easier and more robust. When you build the robotic process workflow, you'll see the following methods available in the Browser module:

  • Close browser
  • Exist element
  • Get attribute
  • Initialize browser
  • Interact with element
  • Navigate to URL
  • Return window title
  • Set sleep default value
  • Set timeout in seconds
  • Set timeout in seconds to use when wait element (Default value: 60)
  • Set type of browser
  • Sleep the default sleep time
  • Sleep the specified time
  • Wait for attribute
  • Wait for window title
  • Wait for window title and activate
  • Wait for window title with timeout
  • Wait for window title with timeout and activate

A few of these methods, described below, are commonly used and contain multiple options to create a specific configuration.

Get attribute

This method lets you find the attribute value of one or more elements on the screen. This method contains the following configurations:

  • Selector: Lets you identify an element on the web page based on a Selenium By class and matching value. The options include:
    • ID
    • Link Text
    • Partial Link Text
    • Name
    • Tag Name
    • XPath
    • Class Name
    • CSS Selector
  • Wait for element: Lets you specify the maximum amount of time the robotic process should wait for the element before moving on. If the element is found before the defined time, it will continue as soon as the element is found. Choose from these options:
    • Use default max wait time: When selected, the robotic process waits for the time you set in the Set timeout in seconds to use when wait element method. If this time elapses without finding the element, the action completes.
    • Enter explicit wait time: When selected, you can enter the maximum time (in seconds) the robotic process should wait. This number must be greater than zero. If this time elapses without finding the element, the action completes.
    • Don't wait: If the element isn't found, the action completes without waiting.
  • Attribute to return: Contains multiple options:

    Display name Returns Description
    Value Text The value of the "value" attribute. Many types of components may contain a "value" attribute, though selection components may find other options more in line with what they're looking for (dropdowns use either Selected dropdown options or First selected dropdown option, while checkboxes and radio buttons may use Is selected?).
    Hypertext reference Text The value of the "href" attribute.
    Inner HTML text Text The text contained within an HTML tag.
    Image source Text The value of the "src" attribute of an image.
    Class name Text The value of the "className" attribute of an element. Many types of components have this attribute, but it will typically only be extracted from visual components such as icons.
    All dropdown options List of Maps Each Map represents WebElement and contains three entries: index, value, and text. If the dropdown does not contain any options, returns an empty list.
    Selected dropdown options List of Maps Each Map represents WebElement and contains three entries: index, value, and text. If no options are selected, returns an empty list.
    First selected dropdown option Map Returns a Map representing WebElement containing three entries: index, value, and text. If no option is selected, returns null.
    Is enabled? Boolean Returns true if the element is enabled or false if it is disabled.
    Is displayed? Boolean Returns true if the element is displayed or false if it exists but is not displayed.
    Is multiple? Boolean Returns true if the dropdown supports selecting multiple options or false if it does not. If this option is used on a component that is not a dropdown, it will return false.
    Is selected? Boolean Returns true if the checkbox or radio button option is selected or false if it is not.
    Other Text varies
  • Take screenshot: Choose whether to take a screenshot of the resource after the action completes. If the action failed, the screenshot is taken immediately before the exception is thrown and cleanup is started. If the action completed successfully, the screenshot is taken immediately after the action is performed. The element may no longer exist on the page, notably if it is a navigation action.
  • Fail if…: Determines the condition under which the action should fail. Available options are:
    • Element not found: After the configured wait time, the element still does not exist on the web page. Use this if the element must be found to continue with the process.
    • More than one element is found: Multiple elements on the page matched the selection criteria as defined in Selector. Use this if you only expected to find one element.
    • Attribute does not exist: None of the attributes match the selected criteria set in Attribute to return. Use this if the specified attribute must be present in all identified elements to continue with the process. If not checked and the attribute doesn't exist, it will return null.

Output

This action will return a list. Each index in the list corresponds to the attribute value of one element. If the attribute for any element isn't found, the value at that index will be null.

Interact with element

This browser method lets you interact with elements on the screen, based on the selection and configurations you specify. This method contains the following configurations:

  • Selector: Lets you identify an element on the web page based on a Selenium By class and matching value. The options include:
    • ID
    • Link Text
    • Partial Link Text
    • Name
    • Tag Name
    • XPath
    • Class Name
    • CSS Selector
  • Wait for element: Lets you specify the maximum amount of time the robotic process should wait for the element before moving on. If the element is found before the defined time, it will continue as soon as the element is found. Choose from these options:
    • Use default max wait time: When selected, the robotic process waits for the time you set in the Set timeout in seconds to use when wait element method. If this time elapses without finding the element, the action completes.
    • Enter explicit wait time: When selected, you can enter the maximum time (in seconds) the robotic process should wait. This number must be greater than zero. If this time elapses without finding the element, the action completes.
    • Don't wait: If the element isn't found, the action completes without waiting.
  • Interaction: Contains multiple options:
    • Click on element
    • Double-click on element
    • Select dropdown choice by index: Value input must be greater than zero.
    • Select dropdown choice by visible text: When you select this option, specify the visible text to find.
    • Select dropdown choice by value: When you select this option, specify the value to find.
    • Select checkbox (if not already selected)
    • Deselect dropdown choice by index: Value input must be greater than zero.
    • Deselect dropdown choice by visible text: When you select this option, specify the visible text to find.
    • Deselect dropdown choice by value: When you select this option, specify the value to find.
    • Deselect checkbox (if already selected)
    • Toggle checkbox
    • Update value: When you select this option, specify the new value.
    • Clear value
  • Take screenshot: Choose whether to take a screenshot of the resource after the action completes. If the action failed, the screenshot is taken immediately before the exception is thrown and cleanup is started. If the action completed successfully, the screenshot is taken immediately after the action is performed. The element may no longer exist on the page, notably if it is a navigation action.
  • Fail if…: Determines the condition under which the action should fail. Available options are:
    • Element not found: After the configured wait time, the element still does not exist on the web page. Use this if the element must be found to continue with the process.
    • More than one element is found: Multiple elements on the page matched the selection criteria as defined in Selector. Use this if you only expected to find one element.
    • Interaction is invalid: The selected interaction can't be executed. Examples of this include attempting to click on a disabled element, attempting to select a dropdown choice from an element that isn't a dropdown, etc. Use this when this interaction is required to continue the process.

Wait for attribute

This method lets you wait for one or more elements to have a specific attribute before the process continues. This method contains the following configurations:

  • Selector: Lets you identify an element on the web page based on a Selenium By class and matching value. The method options include:
    • ID
    • Link Text
    • Partial Link Text
    • Name
    • Tag Name
    • XPath
    • Class Name
    • CSS Selector
  • Wait time: Lets you specify the maximum amount of time the robotic process should wait for the element before moving on. If the element is found before the defined time, it will continue as soon as the element is found. Choose from these options:
    • Use default max wait time: When selected, the robotic process waits for the time you set in the Set timeout in seconds to use when wait element method. If this time elapses without finding the element, the robotic process continues to the next action in the workflow.
    • Enter max wait time: When selected, you can enter the maximum time (in seconds) the robotic process should wait. This number must be greater than zero. If this time elapses without finding the element, the robotic process completes.
  • Attribute value to wait for:
    • Value
    • Hypertext Reference (href)
    • Text (Returns as plain text, contains no HTML)
    • Image Source (src)
    • Class Name
    • Is Enabled?
    • Is Displayed?
    • Is Multiple?
    • Is Selected?
    • Other
  • Take screenshot: Choose whether to take a screenshot of the resource after the action completes. If the action failed, the screenshot is taken immediately before the exception is thrown and cleanup is started. If the action completed successfully, the screenshot is taken immediately after the action is performed. The element may no longer exist on the page, notably if it is a navigation action.
  • Fail if…: Determines the condition under which the action should fail. Available options are:
    • More than one element is found: Multiple elements on the page matched the selection criteria as defined in Selector. Use this if you only expected to find one element.

Using the Browser Java module

If you have a use case that isn't covered by one or more of the low-code code actions, you can fall back to using the Java module. To use the Browser module in your projects, you first must include the module dependency in the pom.xml.

Browser module architecture

The Browser module requires Selenium to work properly and interact with browsers.

Components

This section describes each of the components needed to work with the Appian RPA Browser module:

  • Java Selenium drivers: Appian RPA uses the Selenium WebDriver API, which contains different language-specific implementations, such as Java. The Java implementations, included in the Maven dependency selenium-java, are called drivers. It is important to know this terminology to avoid confusion.
  • Servers: executable programs that drivers communicate with. Drivers use servers to interact with browsers. These servers, sometimes known as proxies, are necessary and are available to download as external components, since they are developed by third parties (except for Internet Explorer). This page uses the term servers to avoid confusion.
  • Browsers: the web browsers to use in the automation. Chrome, Firefox, and Internet Explorer are supported.

The following image shows how all these components are connected:

2234036.png

Different servers available for each supported browser:

Once downloaded, you must add the driver to the robotic process configuration as Support Files. Usually, a robotic process will only have to interact with one browser, so you don't need to upload all the files shown in the image.

2234035.png

Compatibility between components

Not all versions of each component are compatible with each other. We recommend that you always work with the most recent versions of the browsers and their bridge servers. In all cases, they must be compatible with the Selenium version integrated into the Appian RPA Browser module. Visit the links below for each web browser to know what versions are supported for the rest of the components:

Using the Browser module

Initialize the browser and set timeout

The core interface of the Appian RPA Browser module is com.novayre.jidoka.browser.api.IWebBrowserSupport. This interface provides the methods to interact with the browser and the components of a page.

This code snippet calls the interface:

1
2
IWebBrowserSupport browser =
    IWebBrowserSupport.getInstance(this, client);

Where client is an instance of IClient and this is a reference to the robotic process that uses the module.

Once the instance of IWebBrowserSupport is called, we should properly initialize it. Set the browser to use and the default timeout:

1
2
3
// Set the browser to Chrome
browser.setBrowserType(EBrowsers.CHROME);
browser.setTimeoutSeconds(60);

In this example, Google Chrome is set as the browser with a timeout of 60 seconds.

The enumerator type EBrowsers contains the identifiers for all the supported browsers: CHROME, INTERNET_EXPLORER, and FIREFOX.

To set other browsers:

1
2
3
4
5
// Set the browser to Internet Explorer
browser.setBrowserType(EBrowsers.INTERNET_EXPLORER);

// Set the browser to Mozilla Firefox
browser.setBrowserType(EBrowsers.FIREFOX);

Putting it all together, the full code to initialize the Browser module is:

1
2
3
4
5
6
7
8
9
10
// IClient
IClient client = IClient.getInstance(this);

// IWebBrowserSupport
IWebBrowserSupport browser =
IWebBrowserSupport.getInstance(this, client);

// Set the browser to Internet Explorer
browser.setBrowserType(EBrowsers.INTERNET_EXPLORER);
browser.setTimeoutSeconds(60);

Opening the browser and loading a web page

Now that you have properly initialized the browser, you can open it and navigate to a web page. This example will open the browser and visit the Appian website:

1
2
3
4
5
6
// Open browser
browser.initBrowser();

// Navigate to a URL
String url = "http://www.appian.com";
browser.navigate(url);

FAQ

To use the Browser module, I need three components. How can I know which version of each component to use?

Appian RPA relies on the Selenium WebDriver API to simulate user interaction in the browsers. Consult the Selenium documentation below for your browser and your browser version. Refer to the Browser module architecture for instructions on how to configure the robotic processes.

Browser Page
Firefox https://firefox-source-docs.mozilla.org/testing/geckodriver/Support.html
Chrome https://sites.google.com/a/chromium.org/chromedriver/downloads
IE11 https://raw.githubusercontent.com/SeleniumHQ/selenium/master/cpp/iedriverserver/CHANGELOG

For further information, go to the Selenium website.

How can I move through tabs that open in the browser?

When a new tab is opened by the browser either automatically or as the result of a user action, you are required to explicitly switch to this tab if you want to interact with it.

To change from one tab to another in the Browser module, you must call the switchTo() method as described below:

  • Get the open windows/tabs using the driver with the method browser.getDriver().getWindowHandles();
  • Switch to the desired window/tab using the method browser.getDriver().switchTo().window(…);

Example:

1
2
3
List<String> tabs = new ArrayList<String>(browser.getDriver().getWindowHandles());

browser.getDriver().switchTo().window(tabs.get(tabs.size() - 1));

The Browser module does not locate an element I'm visualizing in the browser inspector because it is in another frame. How do I access it?

To access the elements contained in another frame or another pop-up window, you must be positioned inside it. Using the element inspector of the browser, get the name of the frame containing the element to find and use it in the method browser.frameSetNavigation(String frame).

Can I use JavaScript in my robotic process code?

Yes, the Browser module is developed from Selenium and the developer can use all the options that Selenium offers by getting the driver invoking browser.getDriver().

To run JavaScript, use the following code:

1
2
3
JavascriptExecutor jsExecutor = ((JavascriptExecutor) browser.getDriver());

jsExecutor.executeScript("YOUR CODE HERE");

The findElement(By by) method take a lot of time when the WebElement is not present. Why?

The purpose of the method findElement is to wait for a page to be completely loaded and to find an element on this page. As such, this method uses the default timeout defined in the Browser module (60 seconds). This means that if the element is not present on the page, the method keeps looking for up to 60 seconds.

To find a WebElement that is not always present in the page, use one of the following options:

  • Use the existsElement() method, which has a shorter default timeout.

    1
    2
    3
    4
    5
    
      if (browser.existsElement(By.xpath("//xpath/expression"))) {
            server.info("Doesn't exist the element");
      } else {
            // ...
      }
    
  • Modify the timeout used by the findElement method: browser.setTimeOutSecondsWaitElement(int second);

If you change this timeout for a specific action, it is recommended to restore it afterwards.

Tutorial: Build a browser bot

Learn how to use the browser module in a robotic process

Use these tutorials to learn more about the Browser module:

Open in Github

On This Page

FEEDBACK