Updated April 4, 2023
Introduction to Selenium IDE Commands
Generally, selenium ide commands are called as selenese. These selenese are known as a set of commands, which can be used in selenium ide. As we have known, all these selenium ide commands are used to test web applications. With this selenese, we can perform some actions on web applications as below.
- Testing a web page based on HTML tags
- Testing for specific/required data
- Test for broken links
- For selecting list options
- To submit forms
- Getting data from tables
above are the basic commands that we use in selenium. Besides, selenium IDE commands are used to test the window size of an application, positions of the mouse, pop-up windows, and more. With this selenese, we can test any existing UI elements based on their source, i.e., html tags. We can test for specific content on a webpage and test for broken links, list options, input fields, and table data, etc.,
Types of Selenium IDE Commands
The following are the types of selenium IDE commands.
1. Actions
These selenium IDE commands are used to manipulate the state of an application. Generally, these Actions commands provide events such as.
- click this link
- select an option
- click this box
if the action fails, it automatically stops the testing. Many actions can be called with and wait for the suffix.
Example:
- clickAndWait
- typeAndWait
These suffixes will tell the browser to call on the server. And selenium has to wait for a new page for loading. Below are the commonly used actions commands.
- open(url):
With this command, we can open and access any web page and test it with any web browser.
- close():
This command is used to close to connection/testing/processing a webpage.
- click(locator):
With this command, we can get access to click on the button, check box, link, and radio button, etc.,
- type(locator, value):
It is used to set the input value type based on the user typing actions.
- doubleClick(locator):
This command enables us to double click on a web element. For this action, we need to provide the element to click.
- focus():
This command is used to focus on the specified element.
- store(expression,variable):
This command is used to store values. In the syntax, “expression” is the value to store.
- highlight(locator):
This command is used to highlight the background color of a specified element for debugging purpose.
2. Accessors
These accessors commands are used to examine the state of an application and also used to store the results in a variable. These commands are also used to generate the assertions automatically. Below are the accessors commands:
- storeValue(locator,variable):
This command is used to store the value in a specified location. While storing the value, it will automatically trim the input value.
- storeLocation(variable):
This command is used to get the absolute URL of a webpage. And will stores the location in place of the variable. URL will be the location of the webpage.
- storeTitle(variable):
This command is used to get the title of the webpage.
- storeAllLinks(variable):
This command is used to get all links to the webpage. It will extract the ID’s of all the links on the webpage.
- storeText(locator,variable):
This command will extract the text from the webpage. It will help us to extract the text of an element on the webpage.
- storeTable(tableCellAddress,variableName):
This command is used to extract the text from a cell of the table on the specified webpage. We can get all the data/text from a table on the webpage by providing a cell of the table.
- storeAllFields(variable):
This command is used to store all the input fields on the webpage. Generally, it will store the ID’s of all input fields.
- storeBodyText(variable):
This command is used to get the entire text from a webpage.
3. Assertions
These commands can enable testers to verify the state of an application. Generally, there are three types of assertions as below.
- assert: if the assert fails, the test will be automatically aborted.
- verify: when verify fails, it never stops execution, but it will return logging failure.
- waitfor: it will wait for the condition until it becomes True.
These commands are similar to accessors, but these commands verify the state of an application with the expected result. Below are the commonly used assertions commands.
- verifyBodyText(pattern):
This command is used to verify the body text. It will be used with the accessor store body text.
- waitForAlert(pattern):
This command is used to wait for the alerts on the webpage. This command will be used with the accessor store alert.
- verifyAllButtons(pattern):
This command is used to verify all the buttons on a webpage. It will work with the combination of accessor store all buttons.
- verifyAlert(pattenr):
This command is used to verify the alert text on the webpage. This command will be used with the accessor store alert.
- verifySelected(selectlocator,optionlocator):
This command is used to verifies the selected options of a drop-down on a webpage. And this command will satisfy the optionspecifier for that particular webpage.
- verifyAllLinks(pattern):
This command is used to verify all the links on a webpage. This command is used with the accessor to store all links.
- verifyAttribute(locator,pattern):
This command is used to verify an attribute of an element. This command will work with the accessor store attribute.
- verifyAllWindows(pattern):
This command is used to verify the window’s ID. This command will work with the accessor to store all windows.
Conclusion
Selenium IDE commands allow us to run the entire test script with a single test script. These test scripts in selenium IDE can be created using playback and record features. With these selenium IDE commands, we can set any number of breakpoints to stop the test at any step of execution. When we are working on the selenium IDE commands, we need to remember that not to change the source to the other formats; if we do that, it may cause data loss. As we have a wait for the mechanism, it will wait for some time to meet the condition. If the condition returns true, it will continue the execution.
Recommended Articles
This is a guide to Selenium IDE Commands. Here we discuss the Types of Selenium IDE Commands along with the examples. You may also have a look at the following articles to learn more –