Selenium commands are also called Selenese. Selenese is the set of commands which are used in Selenium IDE. These set of commands are used to test our web applications.
In selenese, one can test the existence of UI elements based on their HTML tags, test for specific content, test for broken links, input fields, selection list options, submitting forms, and table data among other things. In addition, Selenium commands support testing of window size, mouse position, alerts, Ajax functionality, pop up windows, event handling, and many other web-application features.
Selenium IDE Commands (Selenese)
There are three types of Selenium IDE commands:
Actions are commands that generally manipulate the state of the application. They do things like type this box, click this link or select option. If an Action fails, or has an error, the execution of the current test is stopped.
Many Actions can be called with the AndWait suffix, e.g. clickAndWait, typeAndWait. This Suffix tells Selenium that the action will cause the browser to make a call to the server, and that Selenium should wait for a new page to load.
These commands examine the state of the application and store the result in variables, Like storeTitle. They are also used to automatically generate Assertions.
These commands are like accessors, but they verify that the state of the application conforms to what is expected.
Now the Selenium Assertions can also be categorized into three categories:
- Assert: When an ‘Assert’ fails, the test is aborted.
- Verify: When a ‘Verify’ fails, the test will continue execution, logging the failure.
- WaitFor: Wait for some condition to become true. They will succeed immediately if the condition is already true. However, they will fail and halt the test if the condition does not become true within the current timeout setting.
Commonly used Selenium IDE commands:
- type: Sets the value of an input field, as though you typed it in.
- open: Opens a page using a URL.
- click: Clicks on a link, button, checkbox or radio button.
- clickAndWait: Clicks on a link, button, checkbox or radio button. If the click action causes a new page to load (like a link usually does), call waitForPageToLoad.
- select: Select an option from a drop-down using an option locator.
- selectFrame: Selects a frame within the current window.
- verifyTitle/assertTitle: Verifies an expected page title.
- verifyTextPresent: Verifies that the specified text pattern appears somewhere on the rendered page shown to the user.
- verifyElementPresent: Verifies that the specified element is somewhere on the page.
- waitForPageToLoad: Waits for a new page to load. You can use this command instead of the “AndWait” suffixes, “clickAndWait”, “selectAndWait”, “typeAndWait” etc.
- highlight: Briefly changes the backgroundColor of the specified element yellow. Useful for debugging.
- pause: Wait for the specified amount of time (in milliseconds)
- store: The name of a variable in which the result is to be stored. This command is a synonym for storeExpression.
- echo: Prints the specified message into the third table cell in your Selenese tables. Useful for debugging.
- refresh: Simulates the user clicking the “Refresh” button on their browser