Selenium IDE Commands | Selenese Commands
Hope you are keeping up so far with all the Selenium lessons. We will learn about the types of Selenium IDE commands in this post. The previous chapter on how to use Selenium IDE in Firefox helped us to create a good niche into the world of Selenium IDE. Make sure you have gone through it before you understand the Selenese commands we are going to talk about here.
As you might remember from the Selenium IDE suite, that there used to be commands in the Editor pane with targets and values.
This shall jog your memory:
When you right click on a blank space on a webpage while testing something you get all the available commands that you could use in order to test the page.
So this chapter will try to see what types of Selenium IDE commands are really there, so you don’t end up getting confused when you see all the hotchpotch in the “Show All Available Commands” Menu Item.
Selenium IDE Commands
There are three main types of Selenium IDE Commands. They have been mentioned below:
We will take a look at them one by one.
As the name might suggest, when you are doing something, when you are acting upon something by performing an ‘action’ that’s what this command is all about.
In other words, commands that directly interact with page elements constitute this category.
For example, the click command. When you are clicking on something, it is being counted as an action. You are actually doing something on the page. It will be recorded as a ‘click’ action.
Another example of an action would be the ‘type‘ command. Even here you are typing something which is an action.
There are some commands that let you store values inside a variable. Such commands are known as accessors.
For instance, storeTitle command lets you store the title of the webpage in a variable.
There is no interaction here unlike action command.
The third type of Selenium IDE commands is known as Assertions. Assertions assure whether a condition is met or not.
In this also there are three types namely:
You make use of Assert when you want the test to abort. When an Assert command is encountered the test is stopped immediately. It doesn’t proceed with the rest of the commands that are in line.
Here I am taking an example to show you how the execution doesn’t proceed.
I had a click command entered in the second step but it isn’t picked up. Test case fails and exits.
Verify on the other hand logs the failure in the error log, however, does not stop the execution.
We will check this as well.
My second step in the above was clicking the pictorial google element that was going to navigate me to James Wong Howe. As you can see the execution was carried out nevertheless despite it encountering an error in the first step itself.
The third type WaitFor command basically means exactly what its name suggests. It will wait for a condition to become true before proceeding with the test execution.
There are plenty of WaitFor Commands available. I am using WaitForTitle command here to show you a scenario.
I clicked on Execute Test case and waited for 30 whole seconds after which the error message was established. Clearly there was no Title named as Google on this page, and hence the condition failed.
By default, the wait time is for 30 seconds. If the condition is not satisfied for 30 seconds it will automatically fail the condition and a failure message will be logged. However, it will still go on to proceed with the next step.
You can also change this default time from 30 seconds to more or less by navigating to Options > Options… which opens the Selenium IDE Options dialog:
The first General tab will hold the option of changing the timeout value. Just change it as per your liking.
A List of Some Common Selenese Commands
I am going to list some of the common Selenese commands that you might see while testing. These are:
- open – We saw this earlier. It helps in opening page via a URL
- type – When you have something to type from the keyboard
- click – Clicks on an element
- verifyTextPresent – You can use this command to verify if a certain text is present on the page or not
- verifyElementPresent – Checks whether certain element is present or not
- verifyTitle – You can use this to verify the title of the page opened
- assertTitle – We already saw that, does the same thing but fails further execution if condition false
- verifyTable – Checks the content of a table and matches it against specified values
- waitForPageToLoad – Execution is paused until your page gets loaded fully
- waitForElementPresent – Waits till it establishes your element’s presence.
With that I hope you got the gist of what you are dealing with when you are trying to fathom Selenium IDE.
Let’s call it a day and hope to test some coarse test conditions in upcoming chapters.