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 are 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, and open fall 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 is 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 fall under assertions. When we use the assert command, the test will stop immediately if the command fails. When verify type commands fail 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.
Table of Contents
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 a browser web console for locating the elements. You may also install and use the 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. https://www.siteforinfotech.com) for which you are going to test. If the record button is automatically selected, turn it off.
Step 3: To insert a new command, go to the command editor table and click on the topmost line. Choose the open command from the drop-down option and write the test URL on the 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 the appropriate element locator or click on the button “select target in the page” and click on the target element on the page. Write on the value and description field if required.
Step 5: Click on the “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 them by specifying a name.
Setting Start Point, BreakPoint, and Executing a Command
When writing test scripts you may specify the 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 by right-clicking on the command line or clicking on vertical dots and clicking on “Play from here”. It can also be activated by pressing the shortcut key ‘S’ after clicking on the 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 the 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 by executing even a single command line. In order to execute a command, you have to select the command line which you want to execute 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.
Read Next: Common Selenium IDE Commands Lists