In the previous article, you have learned in detail about installing the Selenium IDE and the methods of recording test cases automatically. Now, in this tutorial, you will learn on how to write test cases manually in selenium IDE. Selenium uses the set of commands to run your test cases. The sequence of commands used while creating the test cases is called the test script. Click, type, select, double-click, verify, add selection, check, open etc. are the basic commands used on selenium IDE. The set of commands which can test your web application virtually often called selenese.
Based on their functionalities, the following are the types of commands used in selenium.
- Actions: The selenium commands which will manipulate the state of the application called actions. These types of commands will directly interact with the page elements for performing some actions. The commands such as click, double click, select, check, open falls under actions. If the action fails while running the test script, it will stop executing the test case.
- Accessors: We will use accessors to examine the state of an application and store some values in some variables. They will not interact with any element on the page. The commands such as the store, store attribute, store text, store value, store title etc. fall under accessors.
- Assertions: The set of commands are called assertions if they can verify the state of the application and also verify the expected results. Three types of commands assert, verify and wait for falls under assertions. When we use assert command, the test will stop immediately if the command fails. When verify type commands fails while executing the test cases, it will continue executing with recording the logs. Wait for commands will wait for some conditions to be true before executing the next command.
Writing Test Cases Manually in Selenium IDE
Along with automatically recording you may also write the test cases manually by typing commands in selenium IDE. While writing scripts for the test case, you have to locate the elements on the web application which you are testing. You can inspect the elements with browser web console for locating the elements. You may also install and use Firebug addon to inspect the elements more easily and quickly.
Use the following steps to start writing test cases manually in selenium IDE.
Step 1: Open the selenium IDE from your browser from which you have already installed. If you are not installed the selenium IDE to your browser yet, refer to this article.
Step 2: Click on the link “Record a new test in a new project”, provide the name of the project and go next. Type the base URL (i.e. http://www.siteforinfotech.com) for which you are going to test. If record button is automatically selected, turn it off.
Step 3: To insert a new command, go to command editor table and click on the topmost line. Choose open command from drop down option and write test URL on target field then press enter.
Step 4: Go to the next line on the command editor table and click on it. Select a command and navigate to the target field. Write appropriate element locator or click on the button “select target in page” and click on the target element on the page. Write on value and description field if required.
Step 5: Click on “Find the target on the page” button in order to verify whether the IDE will identify the element which you are locating.
Step 6: When you have completed writing test scripts save it with specifying a name.
Setting Start Point, BreakPoint and Executing a Command
When writing test scripts you may specify start point manually from where the test execution will start while running the test case. You can set the start point for a test case with right-clicking on the command line or clicking on vertical dots and clicking on “Play from here”. It can also be activated with pressing the shortcut key ‘S’ after clicking on command row.
You can also set up the breakpoint for a test script from where you want to pause the test automatically while running the test case. For setting up the breakpoints, click on the command line where you want to place the breakpoint, right click on the line or click on vertical dots and click on “Toggle breakpoint”. The shortcut key for activating breakpoint is ‘B’. You can set multiple breakpoints for a single test case.
While writing the test cases manually, If you want to verify whether the command you have set properly works or not, can check with executing even a single command line. In order to execute a command, you have to select the command line which you want to execute the right click on the line or click on vertical dots and click on “Execute this command”. You may also use the shortcut key ‘X’ to execute the command after clicking on that line.