• Selenium Video Tutorials

Selenium IDE - Selenese Commands



Every command used in Selenium IDE is known as the Selenese commands. Using the Selenese commands we perform all the testing activities on a web application. Selenese commands are of three types −

Thus Selenese is a language which is used to create test automation using Selenium IDE. We can also define Selenese in Selenium IDE commands. These Selenese commands can be used extensively to test the functionalities of the web applications.

Basic Actions Commands

The action commands are used to manipulate the state of the application under test. There various types of actions commands available in Selenium IDE.

  • click(locator)
  • check(locator)
  • uncheck(locator)
  • choose cancel on next confirmation
  • choose cancel on next prompt
  • choose ok on next confirmation
  • click At(locator, coordinateString)
  • close
  • debugger
  • double click(locator)
  • double click at(locator)
  • drag and drop to object(source locator, destination locator)
  • echo(message)
  • edit content(locator, value)
  • execute script(script, variable name)
  • execute async script(script, variable name)
  • mouse down(locator)
  • mouse down at(locator, coordinateString)
  • mouse move at(locator, coordinateString)
  • mouse out(locator)
  • mouse over(locator)
  • mouse up(locator)
  • mouse up at(locator, , coordinateString)
  • open(url)
  • pause(wait time)
  • remove selection(locator, option)
  • run(test case)
  • select(locator, option)
  • select frame(locator)
  • select window(window handle)
  • set window size(resolution)
  • type(locator)

Basic Accessors Commands

The accessors commands are used to manipulate the state of the application under test.

The following are the accessors command −

  • store(text, variable)
  • store attribute(locator, variable)
  • store text(locator, variable)
  • store title(text, variable)
  • store value(locator, variable)
  • store window handle(window handle)
  • store xpath count(xpath, variable)

Basic Assertions Commands

The assertion commands are used to check the state of the application under test. There various types of assertions commands available in Selenium IDE.

  • assert(variable, expected value)
  • assert alert(alert text)
  • assert checked(locator)
  • assert confirmation(text)
  • assert editable(locator)
  • assert element present(locator)
  • assert element not present(locator)
  • assert not checked(locator)
  • assert not editable(locator)
  • assert not selected value(locator, text)
  • assert not text(locator, text)
  • assert prompt(text)
  • assert selected value(locator, text)
  • assert selected label(locator, text)
  • assert text(locator, text)
  • assert title(text)
  • assert value(locator, text)
  • verify(variable, expected value)
  • verify checked(locator)
  • verify editable(locator)
  • verify element present(locator)
  • verify element not present(locator)
  • verify not editable(locator)
  • verify not selected value(locator, text)
  • verify not text(locator, text)
  • verify selected label(locator, text)
  • verify selected value(locator, text)
  • verify text(locator, text)
  • verify value(locator, text)
  • wait for element editable(locator, wait time)
  • wait for element not editable(locator, wait time)
  • wait for element not present(locator, wait time)
  • wait for element not visible(locator, wait time)
  • wait for element present(locator, wait time)
  • wait for element visible(locator, wait time)

Example

Let us take an example of the below page, where we would capture the page title Selenium Practice - Radio Button taking the help of the accessors commands. Then click on the radio button beside the Yes label using the actions commands.

Selenium Selenese Commands 1

After selecting the radio button, we would get the text - You have checked Yes, which we would verify using the assertions command.

Selenium Selenese Commands 2

The steps to be followed are listed below −

Step 1 − Click on the Selenium IDE extension visible on the browser after its installation.

Step 2 − Selenium IDE should be launched along with it, a welcome message should be displayed with the version of the tool. In the below image, the version installed is 3.17.2.

Along with this, it gives us the option to select what we would like to do with the tool, like Record a new test in a new project, Open an existing project, Create a new project, and Close Selenium IDE.

Also, a link with the text - the Selenium IDE project page is provided, which on clicking would land us to the Selenium Integrated Development Environment documentation page.

https://www.selenium.dev/selenium-ide/.

Selenium Selenese Commands 3

Step 3 − Click on the Create a new project link, then enter a project name, say, Test8 under the Please provide a name for your new project. Finally, we would click on the OK button.

Step 4 − We would have the workspace ready in the Selenium IDE now.

Selenium Selenese Commands 4

Step 5 − Enter open in the Command field, and Selenium Automation Practice Form in the Target field, to launch the application.

Step 6 − Enter store title in the Command field, and pageTitle in the Value field. Please note, pageTitle is variable to capture the title of the page launched.

Step 7 − Enter echo in the Command field, ${pageTitle} in the Target field. Please note, this would print the text we obtained in Step6 under the Log in Selenium IDE.

Step 8 − Enter click in the Command field, xpath=/html/body/main/div/div/div[2]/form/div[1]/input in the Target field. Please note, xpath=/html/body/main/div/div/div[2]/form/div[1]/input is the locator value of the radio button.

Step 9 − Enter assert element present in the Command field, xpath=//*[@id="check"] in the Target field. Please note, xpath=//*[@id="check"] is the locator value of the text - You have checked Yes.

Step 10 − Enter close in the Command field to close the browser window.

Selenium Selenese Commands 5

Step 11 − Click on the three dots appearing at the left pane, then select the Rename option.

Step 12 − Enter a name, say Test9 under the Rename Test case field, then click on Rename. The entered name would appear on the left of Selenium IDE.

Step 13 − Click on the Run all tests from the top, and wait for the test execution to complete. In our example, we would see Runs: 1, Failures: 0, and a green bar denoting the test ran successfully without any failures. Also, the message that the completed successfully appeared under the Log.

Selenium Selenese Commands 6

In the example above, we had launched the application with open command and obtained the page title Selenium Practice - Radio Button under the Log with the help of the store title command. We clicked on the radio button using the click command and verified the text - You have checked Yes with the help of the assert element present command. Besides, we got a green tick beside the test case name - Test9 at the top, signifying a passed test.

This concludes our comprehensive take on the tutorial on Selenium IDE - Selenese Commands. We’ve started with describing a Selenese command, and various accessors, actions, and assertions commands and an example to walk through how to use the Selenese commands along with Selenium.

This equips you with in-depth knowledge of the Selenese commands in Selenium IDE. It is wise to keep practicing what you’ve learned and exploring others relevant to Selenium to deepen your understanding and expand your horizons.

Advertisements