Open In App

Selenium IDE-Commands

Last Updated : 10 Aug, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

Selenium is one of the most popular open-source tools that facilitate test automation. In Selenium IDE, test scripts can be created in various programming languages like Java, C#, Python, etc. Selenium only allows the testing of web applications. Selenium is a suite of tools, each tool serves different testing needs.

Selenium IDE Commands

In Selenium IDE, the commands that create test cases are referred to as Selenese commands. Selenese are sets of commands that are used in Selenium ide to perform various operations on the web. It is majorly used to develop coding scripts in Selenium IDE. The element locator helps Selenium to decide which HTML element a command will refer to. All of these locators are detectable using Mozilla’s FirePath and FireBug plugins.

One can perform multiple actions on web browsers by using Selenese:

  • Evaluating web pages.
  • Checking for broken links.
  • Testing of input fields.
  • Checking for specific content.
  • Submission of forms and table data.
  • Testing window size and mouse options.
  • Evaluating alerts.

Types of Selenium Commands

Selenium commands(Selenese) are classified under three categories, Actions, Accessors, and Assertions.

Actions

Actions are selenium IDE commands that control the status of an application. Actions commands provide multiple events like:

  • Click on this link.
  • Decide and select an option.
  • Click on this box.

For some reason, if an action fails, the execution of the current test automatically stops. Below are the frequently used actions commands:

Command

Description

open (URL)

This command opens specific URLs, and this command is used for both relative and absolute URLs.

get(URL)

This command opens a specific URL in the browser.

find_element(by, value)

This command finds a single web element using different strategies.

click ()

This command allows clicking on web elements like links, buttons, checkboxes, or radio buttons.

clickAt (locator, coord)

This command allows you to click on an element with the help of pointers and coordinate strings.

doubleClick ()

This command allows a double click on the web element based on the specified content.

focus ()

This command moves the focus to a specified web element.

highlight ()

This command changes the web element’s background color to yellow for priority, which is essential for debugging purposes.

refresh()

This command allows clicking on the refresh button.

pause(time)

This command allows waiting for a specific amount of time in milliseconds.

close()

This command closes the current browser window that the WebDriver is using.

mouseUp()

Upon releasing the mouse button, this command reproduces the event that occurs.

mouseUpAt(locator, coord)

Upon releasing the mouse button at a particular location, this command reproduces the event that occurs.

mouseDown()

This command is used to perform left mouse click operation.

mouseDownAt (locator, coord)

Upon releasing the left mouse button at a particular location, this command reproduces the event that occurs.

echo(statement)

This command prints specified messages or statements on the console.

Accessors

Accessors are the selenium commands that are used to check the state of the application and store the result in a variable. Accessors commands are generally used to automatically generate Assertions. Below are some commonly used Accessors commands:

Command

Description

storeConfirmation (variable_Name)

This command fetches the JavaScript confirmation generated during past action.

storeTable (tableCellAddress, variable_Name)

This command extracts the text from the cells of the table.

storeTitle (variableName)

This command fetches the title of the current page.

storeText (locator, variable_Name)

This command fetches the content/text of an element.

storeAllWindowNames (variable_Name)

This command prints all the Windows names in an array.

storeAllWindowTitles (variable_Name)

This command prints all the Windows titles in an array.

storeBodyText (variable_Name)

This command fetches the whole text of the page.

storeLocation (variable_Name)

This command fetches the actual URL of the current page.

storeAttribute (locator, variable_Name)

This command fetches the element attributes’ value.

storeAllFields (variable_Name)

This command prints the IDs of all input fields on the page.

storeAllLinks (variable_Name)

This command prints the IDs of all links on the page.

storeVisible (locator, variable_Name)

This command checks if the specific element is visible or not.

Assertions

Assertions are the selenium commands that enable the testers to check/verify the status of an application. Different types of Assertions are:

  • assert: If the assert fails, the test will be terminated automatically.
  • verify: It doesn’t stop execution when verify fails, but returns logging failure.
  • waitfor: It’ll hold up for the condition until it becomes True.

Command

Description

verifySelected(select_Locator, option_Locator)

This command verifies the selected option in the dropdown that meets the optionsSpecifier.

verifyAttribute(attributeLocator, pattern)

This command confirms an attribute of an element; utilized with the accessorstoreAttribute.

waitForErrorOnNext (message)

This command conforms Holds up for mistake; utilized with the accessorassertErrorOnNext.

verifyAllWindowIds (pattern)

This command confirms the window id; utilized with the accessorstoreAllWindowIds.

verifyAllLinks (pattern)

This command confirms all linksutilized with the accessorstoreAllLinks.

verifyAlert (pattern)

This command confirms the alarm content; utilized with accessorstoreAlert.

verifyBodyText(pattern)

This command confirms the body content; utilized with the accessorstoreBodyText.

verifyAllButtons (pattern)

This command confirms the button which is utilized with accessorstoreAllButtons.

waitForAlert (pattern)

This command conforms holds up for the alert; utilized with the accessorstoreAlert.

waitForConfirmation(pattern)

This command waits for the confirmation, utilized with accessor storeConfirmationPresent.



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads