Concepts
Actions are commands that generally manipulate the state of the application. They do things like "click this link" and "select that option". If an Action fails, or has an error, the execution of the current test is stopped.
Accessors examine the state of the application and store the results in variables, e.g. "storeTitle".
Assertions are like Accessors, but they verify that the state of the application conforms to what is expected. Examples include "make sure the page title is X" and "verify that this checkbox is checked".
Commands often use locators to find and match elements on a page. For an explanation of how this functions look here: https://thenewcircle.com/static/bookshelf/selenium_tutorial/locators.html |
Actions
click Clicks on a link, button, checkbox or radio button
close Simulates the user clicking the "close" button in the titlebar of a popup window or tab.
open Opens an URL in the test frame.
select ( selectLocator,optionLocator ) Select an option from a drop-down using an option locator. selectLocator locates the dropdown in the same manner as click. optionLocator selects the option from the dropdown as follows: "label={text-of-option}"
selectWindow Selects a popup window using a window locator; once a popup window has been selected, all commands go to that window. To select the main window again, use selectWindow(null). The popup window can be chosen with 'title={title-of-window}'
type ( locator,value ) Sets the value of an input field, as though you typed it in. |
|
|
Accessors
In the following functions variableName is the name of the variable to be stored. This variable is used to access the value in later commands by accessing it with ${variableName}
storeAttribute(attributeLocator, variableName) Gets the value of an element attribute. attributeLocator is an element locator followed by an @ sign and then the name of the attribute fx. "div#button@name".
storeLocation (variableName) Gets the absolute URL of the current page.
storeText(locator, variableName) Gets the text of an element.
storeTitle(variableName) Gets the title of the current page.
storeXpathCount(xpath, variableName) Returns the number of nodes that match the specified xpath, eg. "//table" would give the number of tables.
storeElementPresent(locator, variableName) Verifies that the specified element is somewhere on the page. |
|
|
Assertions
There are three modes of each assertion: assert, verify, and waitFor.
waitFor commands waits until some condition become true. If the condition has not become true within a specified time-out, test will be considered as failed.
If a verify command is failed the test script continues to run with the entry in the error log.
If assert command is failed the test script is aborted.
The following four commands can be used with all the modes, but are only shown with assert.
assertTitle(pattern) Check the title of the page against the pattern.
assertElementPresent(locator) Check that the specified element is present somewhere on the page.
assertChecked(locator) Check that the specified element is checked or not.
assertAlert(pattern) Check the message of a JavaScript alert and click OK. |
|