Breakpoints in Selenium
Breakpoints are used to tell the Selenium IDE where to pause the test or stop the execution of the test script. This is done to verify that your code is working as expected or not.
Breakpoints, in other words, helps in debugging the test script.
To set breakpoints in the script, you can either right-click on the command and select the ‘Toggle Breakpoint,’ or you can use the shortcut key “B” from the keyboard. The breakpoint can be set just before the Test Case you want to examine. After breakpoints are set, click on the Run button to run the test case from the start until the breakpoint. To deselect the Breakpoint, repeat the same step.
Let us take an example to validate ‘username’ and ‘password’ while we click on the ‘Sign in’ button.
Step 1: Launch Firefox and Selenium IDE in your system.
Step 2: Type the URL http://newtours.demoaut.com/
Step 3: Then click on the Record button on the topmost portion of Selenium IDE, as shown below.
Step 4: Right-click on the command “click” and select the “Toggle Breakpoint’ option, or you can also use the shortcut key “B.”
It implies two things,
- The yellow line shows that the test case is paused at that command.
- There can be multiple breakpoints in the test script.
StartPoint in Selenium
Start Point tells the Selenium IDE from where to start the execution. Start Point can be used anywhere in the test script, either in the middle of the code or a breakpoint. It also helps in debugging the test script.
Let us now take an example of the login scenario to understand the concept of the start point. Suppose you have to log in to the website and want to perform several tests and then want to try to debug any one of those tests.
So, in this case, you log in once and re-run your tests. For this, you can set the Start Points after login function. So that every time you want to perform a new test, it will then begin executing after the login function only.
To select the Start Point in Selenium IDE, right-click on any command and choose the option ‘Play to this Point,’ or you can also use the shortcut key ‘S’ from the keyboard. To deselect the start point, repeat the same step.
Step 1: Launch Firefox and Selenium IDE in your system.
Step 2: Type the URL http://newtours.demoaut.com/
Step 3: Then click on the Record button on the topmost portion of Selenium IDE, as shown below.
Step 4: Right-click on the command “click” and select the “Play to this point’ option, or you can also use the shortcut key “S.”
Please note that there can only be one Start Point in a single test script. Also, Start Point depends on the currently displayed page, and the execution will fail if the user is on the wrong page.