• Selenium Video Tutorials

Selenium IDE - Script Debugging



Selenium IDE provides multiple script debugging options with the help of which we can troubleshoot scripts on failures, or for any other purposes. A debugging of a script is done to ensure that the script should run as it is intended to do by investigating and solving errors, if any.

There are multiple debugging techniques and features available in Selenium IDE.

Step-By-Step Execution

The Step over current command button allows you to run the test step by step and examine if something is not working.

Selenium Script Debugging 1

On clicking on this button repeatedly, we can see if any of the test steps are not working as expected. In the below image, the step 1 executed successfully, after we clicked the Step over current command button. Then Paused in debugger appeared along with the next step to be executed(here the step2) became yellow.

Selenium Script Debugging 3

In the below image now it shows another button Resume test execution. We can also click on it and re-trigger the execution.

Selenium Script Debugging 2

Once again when the Step over current command button is clicked, the step2 will be executed, and so on.

Selenium Script Debugging 4

As the execution has been completed, we would get the message of the result. In case the test passed, we would get the message - <TEST NAME> completed successfully under the Log tab at the bottom of the Selenium IDE. Here, our test name is Test4, hence received the message - Test4 completed successfully.

Apart from that, all the test steps, along with the test case name turned green, reflecting a PASS for all the steps. All the steps which reflected under the Log tab, showed an OK in green.

Adding Breakpoints

We can click on the line numbers in the test to add breakpoints in order to debug test steps in Selenium IDE. In the below image, we have added breakpoints to line numbers 2, and 3 (highlighted in blue in Selenium IDE).

Selenium Script Debugging 5

After which, when we run the test, the execution will first automatically stop in line 2. Then the Paused in debugger appeared along with the next step to be executed (here the step2) becomes yellow.

We will click again on the Step over current command button which will help us to continue with the next step of execution.

Selenium Script Debugging 6

The same process will be repeated, once we move to the next step.

Selenium Script Debugging 7

Once the execution would be completed, we would get the message of the result. In case the test passed, we would get the message - <TEST NAME> completed successfully under the Log tab at the bottom of the Selenium IDE. Here, our test name is Test4, hence received the message - Test4 completed successfully.

Apart from that, all the test steps, along with the test case name turned green, reflecting a PASS for all the steps. All the steps which reflected under the Log tab, showed an OK in green.

Selenium Script Debugging 8

We can disable all the breakpoints by clicking the Disable breakpoints button. All breakpoints would get enabled on clicking the same button again.

Selenium Script Debugging 9

The breakpoints can also be removed/added to steps by right clicking on any step, and selecting the option Toggle Breakpoint.

Selenium Script Debugging 10

Debugger Command

We can programmatically pause Selenium IDE tests by using the JavaScript command debugger. We would need to right click on a step and select the option Insert new command.

Selenium Script Debugging 11

Enter debugger in the Command field to pause the execution.

Selenium Script Debugging 12

Once the test execution is triggered, the control will stop in the debugger step and we will need to resume execution using the Resume test execution button. Then the Paused in debugger along with the test name would become yellow.

Selenium Script Debugging 13

Once the execution would be completed, we would get the message of the result. In case the test passed, we would get the message - <TEST NAME> completed successfully under the Log tab at the bottom of the Selenium IDE. Here, our test name is Test5, hence received the message - Test5 completed successfully.

Apart from that, all the test steps, along with the test case name turned green, reflecting a PASS for all the steps. All the steps which reflected under the Log tab, showed an OK in green.

Selenium Script Debugging 14

Pause on Exceptions

The Pause on Exception feature in Selenium IDE helps to pause the exception of a test in case an error is encountered. Once paused, we can rectify the step and resume execution.

Let us take the example discussed previously, and intentionally we would fail a step in that test case, by changing the locator id value in line 2. Here, we have changed the locator value to id=names.

Selenium Script Debugging 15

Once the execution is completed, we would get the failed test and the rest of the test steps after the failed step would not get executed.

Selenium Script Debugging 16

However, to prevent the execution from being aborted, we would need to click on the Pause on exceptions button, and then run the test again.

Selenium Script Debugging 17

In the below image, the execution stopped at line 2 (due to incorrect locator value) with the Paused in debugger along with the test name turning yellow.

Selenium Script Debugging 20

We will correct the locator value from id=names to id=name and again click on the Resume test execution button.

Selenium Script Debugging 18

Once the execution would be completed, we would get the message of the result. In case the test passed, we would get the message - <TEST NAME> completed successfully under the Log tab at the bottom of the Selenium IDE. Here, our test name is Test5, hence received the message - Test5 completed successfully.

Apart from that, all the test steps, along with the test case name turned green, reflecting a PASS for all the steps. All the steps which reflected under the Log tab, showed an OK in green.

Selenium Script Debugging 19

This concludes our comprehensive take on the tutorial on Selenium IDE - Script Debugging. We’ve started with describing an example and walked through the different debugging strategies like the step-by-step execution, adding breakpoints, debugger command, Pause on exceptions, and illustrating how to use them along with Selenium. This equips you with in-depth knowledge of the debugging strategies in Selenium IDE. It is wise to keep practicing what you’ve learned and exploring others relevant to Selenium to deepen your understanding and expand your horizons.

Advertisements