Within Selenium IDE you have the ability to do some interesting stuff through debugging.
When creating a test, or trying to modify, or understand the problems in a test, there is the ability to set up breakpoint, or several breakpoints. What that will do when you run it, is you set a breakpoint, you run a test and when it reaches that breakpoint, the execution of the test will pause. And the application that you're testing will still be in the state that it was in when the command that paused was reached.
There's a couple of ways to set a breakpoint.
You can right click on a specific command in a test and click “toggle breakpoint”;
There's also a hotkey, the letter B; or
You can click on the number for the step and set a breakpoint.
And you can set more than one breakpoint.
You can also come up here to the menu in the top and click “disable breakpoints” and then when you go ahead and play the test, since it's actually the abstracted test, we can actually play it.
So, it would just stop short of inputting the username. So, we get here, it loads the page, and then before it clicks the “Form Identification” link, so that's where it's paused. And then when we're paused, it says “Paused in debugger”.
And then from here, what you can do is:
Click next to the “pause” symbol. The pause symbol would be if you want to un-pause and “resume test execution” and have it move on.
Or you can click “step over current command”. And what that does is it executes the command and then steps into the next one, and then pauses on the next command.
Then you can click again, this enables you to step through the test step-by-step, and so you could actually, if there's a specific issue, or you need to target a different locator or modify the test as you're actively stepping through it, this is a great tool to level up your test maintenance jobs.
Also, there's the ability to, when executing, to pause on exceptions.
So, if a test runs and then there was an error, it would actually pause and step into the debugger, and then leave the application in the failing state, so that you can actually see, just like you can in the debugger right now, what's happening in the application in your test.
Let's go ahead and stop test execution, I'll remove the debuggers, and I want to show you something else that's useful.
There's a couple of other commands here in the right click menu, aside from “toggle breakpoint”, there's “play to this point”, “record from here”, and “play from here”.
There's the ability to similarly to play and then pause in a specific place. You can just right click, and instead of setting a breakpoint, just click “play to this point”. And it will effectively do the same thing as setting a breakpoint and “click and play”. It just does it for you.
There's the ability to “record from here”. So, say you wanted to start recording after this command. You wanted everything to set up and then start recording. Well, you can do that too. So, we can say record from here, it plays up to that point, and then prompts you saying, "You can now start recording." So, what we have to do is just either confirm that we want to do that or click cancel. We start recording, and now we can see that we've reached the place that we want, and then we have the indicator here, saying "Selenium IDE is recording." And then we can go ahead and click stop. And right now, it has the indication from the previous execution, so don't worry about that with the red.
Also, we have the option of “Play from here”. So, say we want to just continue execution from this command on, we have the ability to do that. But since we're actually not on the correct page, this example is not going to work, so let me choose a better one. We'll click stop to stop execution. We're on the homepage, so we want to start from here, and let's play from here. And then it continued on and it worked.
So that's debugging with breakpoints, and then also some other ways to work with different execution flows in the test.