Selenium Commands – Selenese
Selenium commands, often called selenese, are the set of commands that run your tests.
A sequence of these commands is a test script. That is, these commands essentially create a testing language.
Selenese can have up to a maximum of two parameters:
content, test for links, input fields, selection list options, submitting forms, buttons, table data, etc.
You can refer to the complete list of Selenium IDE commands at this link
http://release.seleniumhq.org/selenium-core/1.0.1/reference.html
Selenium commands are classified as:
The IRCTC webpage is having a title “IRCTC Next Generation eTicketing System”.
We will Verify/Check whether this webpage is having the title or not.
Selenium commands, often called selenese, are the set of commands that run your tests.
A sequence of these commands is a test script. That is, these commands essentially create a testing language.
Selenese can have up to a maximum of two parameters:
- Target
- Value
content, test for links, input fields, selection list options, submitting forms, buttons, table data, etc.
You can refer to the complete list of Selenium IDE commands at this link
http://release.seleniumhq.org/selenium-core/1.0.1/reference.html
Selenium commands are classified as:
- Actions
- Accessors
- Assertions
Actions:
These are the commands that directly interact with page elements.
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". 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.
For Example:
The “click” command is an action because you directly interact with the element you are clicking
The “select” command is also an action because you are selecting an option.
Accessors:
These are the commands that allow us to store the results/values in variables.
For Example:
The “storeTitle” command is an accessor because it only reads the page title and saves it in a
variable. It does not interact with any element on the web page.
Assertions:
Assertions are like Accessors, but they verify that the state of the application conforms to what is
expected. If you want clear cut picture, let me give an example:
The IRCTC webpage is having a title “IRCTC Next Generation eTicketing System”.
We will Verify/Check whether this webpage is having the title or not.
There are 3 types of Assertions
- Assert: When an “assert” command fails, the test is stopped immediately.
- Verify: When a “verify” command fails, Selenium IDE logs this failure and continues with the test execution.
- waitFor: Before proceeding to the next command, “waitFor” commands will first wait for a certain condition to become true.
- If the condition becomes true within the waiting period, the step passes.
- If the condition does not become true, the step fails. Failure is logged, and test execution proceeds to the next command.
- By default, timeout value is set to 30 seconds. You can change this in the Selenium IDE Options dialog under the General tab.
Lets see the following example for verify and compare this with above assert.
In this example, we have used the verifyTitle command and the Test Case execution is completed even though there is an error in second line.
Thus finally we can say that,
- When an “assert” command fails, the test is stopped immediately.
- When a “verify” command fails, Selenium IDE logs this failure and continues with the test execution.
Synchronization Commands
We use Synchronization commands in order to provide the synchronization between the Application and the tool. The following are the Commands that we use:
- wait
- pause
These commands are used to avoid Timeout errors.
Wait:
There are two types of wait commands
- andWait
- waitFor
andWait commands:
We can use these commands if we want to wait for a new page to load before moving onto the next
command.
Examples are:
clickAndWait
typeAndWait
selectAndWait
waitFor commands:
We use these commands if we want to wait for a specified condition to become true before proceeding to the next command (irrespective of loading of a new page).
Examples are:
waitForTitle
waitForTextPresent
Pause:
It tells the test to pause for a while. We use pause command to provide the synchronization between the Selenium IDE tool and application. ie: Wait for the specified amount of time (in milliseconds)
Target Format: pause(waitTime)
Here, waitTime is the amount of time to sleep (in milliseconds)
Example: pause 45000
Selenium – Automation Testing
Store commands:
In Selenium IDE, we use the "store" command to store data in variables.
It can be used to simply store a constant value in a selenium variable.
It takes two parameters, the text value to be stored and a selenium variable.
The below figures explains that we are storing the value "Testuser" into a variable "storeValue"
Here we have stored the value “Testuser” into the variable "storeValue".
Now our task is to type the value “Testuser” in the textbox of IRCTC login username field.
We need to access the value stored in the variable by using ${storeValue}.
We have given the locator for the text box as id=usernameId and typing the value stored in the variable by using ${storeValue}, that is Testuser




No comments:
Post a Comment