org.mule.modules

mule-module-selenium

1.1-SNAPSHOT
Namespacehttp://www.mulesoft.org/schema/mule/selenium
Schema Locationhttp://www.mulesoft.org/schema/mule/selenium/1.0/mule-selenium.xsd
Version1.0
Minimum Mule Version3.2

Module Overview

Selenium WebDriver is a tool for automating testing web applications, and in particular to verify that they work as expected. It aims to provide a friendly API that's easy to explore and understand, which will help make your tests easier to read and maintain.

Summary

Configuration
<selenium:config>
Configure an instance of this module
Message Processors
<selenium:clear>
If the element at the payload is a text entry element, this will clear the value.
<selenium:click>
Click the element at the payload.
<selenium:find-element>
Find the first
WebElement using the given method.
<selenium:find-elements>
Find all elements within the current page using the given mechanism.
<selenium:get>
Load a new web page in the current browser window.
<selenium:get-attribute>
Get the value of a the given attribute of the element.
<selenium:get-current-url>
Get a string representing the current URL that the browser is looking at.
<selenium:get-text>
Get the visible (i.e.
<selenium:get-title>
The title of the current page.
<selenium:is-enabled>
Is the element currently enabled or not? This will generally return true for everything but disabled input elements.
<selenium:is-selected>
Determine whether or not this element is selected or not.
<selenium:send-keys>
Use this method to simulate typing into an element, which may set its value.
<selenium:submit>
If the element at the payload is a form, or an element within a form, then this will be submitted to the remote server.
<selenium:until>
Wait until the condition is successful


Configuration

To use the this module within a flow the namespace to the module must be included. The resulting flow will look similar to the following:

<mule xmlns="http://www.mulesoft.org/schema/mule/core"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:selenium="http://www.mulesoft.org/schema/mule/selenium"
      xsi:schemaLocation="
               http://www.mulesoft.org/schema/mule/core
               http://www.mulesoft.org/schema/mule/core/current/mule.xsd
               http://www.mulesoft.org/schema/mule/selenium
               http://www.mulesoft.org/schema/mule/selenium/1.0/mule-selenium.xsd">

      <!-- here goes your flows and configuration elements -->

</mule>

This module is configured using the config element. This element must be placed outside of your flows and at the root of your Mule application. You can create as many configurations as you deem necesary as long as each carries its own name.

Each message processor, message source or transformer carries a config-ref attribute that allows the invoker to specify which configuration to use.

Attributes
TypeNameDefault ValueDescription
xs:string name Optional. Give a name to this configuration so it can be later referenced.
driver HTMLUNIT Optional. Web driver to use

Message Processors

<selenium:clear>

If the element at the payload is a text entry element, this will clear the value. Has no effect on other elements. Text entry elements are INPUT and TEXTAREA elements.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
element Element located at the payload of the message
Child Elements

<selenium:click>

Click the element at the payload. If this causes a new page to load, this method will block until the page has loaded. At this point, you should discard all references to this element and any further operations performed on this element will have undefined behaviour unless you know that the element and the page will still be present. If click() causes a new page to be loaded via an event or is done by sending a native event (which is a common case on Firefox, IE on Windows) then the method will *not* wait for it to be loaded and the caller should verify that a new page has been loaded.

If this element is not clickable, then this operation is a no-op since it's pretty common for someone to accidentally miss the target when clicking in Real Life

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
element Element located at the payload of the message
Child Elements

<selenium:find-element>

Find the first WebElement using the given method. This method is affected by the 'implicit wait' times in force at the time of execution. The findElement(..) invocation will return a matching row, or try again repeatedly until the configured timeout is reached.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
id Optional. The value of the "id" attribute to search for
linkText Optional. The exact text to match against
partialLinkText Optional. The text to match against
name Optional. The value of the "name" attribute to search for
tagName Optional. The element's tagName
xpathExpression Optional. The xpath to use
className Optional. The value of the "class" attribute to search for * @return The first matching element on the current page
Child Elements
Return Payload
  • A singlel WebElement, or null if nothing matches
Exception Payload
NoSuchElementException If no matching elements are found

<selenium:find-elements>

Find all elements within the current page using the given mechanism. This method is affected by the 'implicit wait' times in force at the time of execution. When implicitly waiting, this method will return as soon as there are more than 0 items in the found collection, or will return an empty list if the timeout is reached.

Only one of the attributes can be used at any given time.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
id Optional. The value of the "id" attribute to search for
linkText Optional. The exact text to match against
partialLinkText Optional. The text to match against
name Optional. The value of the "name" attribute to search for
tagName Optional. The element's tagName
xpathExpression Optional. The xpath to use
className Optional. The value of the "class" attribute to search for
Child Elements
Return Payload
  • A list of all WebElements, or an empty list if nothing matches

<selenium:get>

Load a new web page in the current browser window. This is done using an HTTP GET operation, and the method will block until the load is complete. This will follow redirects issued either by the server or as a meta-redirect from within the returned HTML. Should a meta-redirect "rest" for any duration of time, it is best to wait until this timeout is over, since should the underlying page change whilst your test is executing the results of future calls against this interface will be against the freshly loaded page. Synonym for to(String).

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
url The URL to load. It is best to use a fully qualified URL
Child Elements

<selenium:get-attribute>

Get the value of a the given attribute of the element. Will return the current value, even if this has been modified after the page has been loaded. More exactly, this method will return the value of the given attribute, unless that attribute is not present, in which case the value of the property with the same name is returned. If neither value is set, null is returned. The "style" attribute is converted as best can be to a text representation with a trailing semi-colon. The following are deemed to be "boolean" attributes, and will return either "true" or "false":

async, autofocus, autoplay, checked, compact, complete, controls, declare, defaultchecked, defaultselected, defer, disabled, draggable, ended, formnovalidate, hidden, indeterminate, iscontenteditable, ismap, itemscope, loop, multiple, muted, nohref, noresize, noshade, novalidate, nowrap, open, paused, pubdate, readonly, required, reversed, scoped, seamless, seeking, selected, spellcheck, truespeed, willvalidate

Finally, the following commonly mis-capitalized attribute/property names are evaluated as expected:

  • "class"
  • "readonly"

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
element Element located at the payload of the message
name The name of the attribute.
Child Elements
Return Payload
  • The attribute's current value or null if the value is not set.

<selenium:get-current-url>

Get a string representing the current URL that the browser is looking at.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
Child Elements
Return Payload
  • The URL of the page currently loaded in the browser

<selenium:get-text>

Get the visible (i.e. not hidden by CSS) innerText of this element, including sub-elements, without any leading or trailing whitespace.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
element Element located at the payload of the message
Child Elements
Return Payload
  • The innerText of this element.

<selenium:get-title>

The title of the current page.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
Child Elements
Return Payload
  • The title of the current page, with leading and trailing whitespace stripped, or null if one is not already set

<selenium:is-enabled>

Is the element currently enabled or not? This will generally return true for everything but disabled input elements.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
element Element located at the payload of the message
Child Elements
Return Payload
  • True if the element is enabled, false otherwise.

<selenium:is-selected>

Determine whether or not this element is selected or not. This operation only applies to input elements such as checkboxes, options in a select and radio buttons.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
element Element located at the payload of the message
Child Elements
Return Payload
  • True if the element is currently selected or checked, false otherwise.

<selenium:send-keys>

Use this method to simulate typing into an element, which may set its value. The payload must be of type WebElement

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
element Element located at the payload of the message
keys Keys to send
Child Elements

<selenium:submit>

If the element at the payload is a form, or an element within a form, then this will be submitted to the remote server. If this causes the current page to change, then this method will block until the new page is loaded.

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
element Element located at the payload of the message
Child Elements
Exception Payload
java.util.NoSuchElementException} If the given element is not within a form

<selenium:until>

Wait until the condition is successful

XML Sample
INCLUDE_ERROR

Attributes
NameDefault ValueDescription
config-ref Optional. Specify which configuration to use.
timeOutInSeconds Optional. The timeout in seconds when an expectation is called
Child Elements
<selenium:conditional>
Nested processor to be executed for evaluating conditions