[Selenium+Java] Breakpoint & Start Point in Selenium IDE

Original URL: https://www.guru99.com/breakpoints-startpoints-selenium.html

Breakpoint & Start Point in Selenium IDE


Breakpoints are used to check the execution of your code. Whenever you implement a breakpoint in your code, the execution will stop right there. This helps you to verify that your code is working as expected. Breakpoints are usually shown in the UI along with the source code.

In this tutorial, you will learn-

Breakpoints in Selenium

Breakpoints in Selenium helps in debugging.

There are two methods to set breakpoints,

  • In the first method,
    • Right click on the command and select the 'Toggle Breakpoint'. You can also use shortcut key "B" from the keyboard.
    • You can set a breakpoint just before the Test Case you want to examine.
    • After setting breakpoints, click on the Run button to run the test case from the start to the breakpoint.
    • Repeat the same step to deselect the Breakpoint.
  • In the second method,
    • Select Menu Bar -> 'Actions' -> select the Toggle Breakpoint. To deselect repeat the same step.

To demonstrate, let us consider the following scenario. Validate 'username' and 'password' when clicked on the 'Sign in' button.

Methods to implement breakpoints in Selenium

First Method:

Step 1) Launch Firefox and Selenium IDE.

Step 2) Type the Base URL as ---> http://newtours.demoaut.com/

Step 3) Click on the Record button (marked in the red box in the screenshot below).

Breakpoint & Start Point in Selenium IDE

Step 4) In this step,

  1. Under the tab "Table" right click on the command ( "clickandwait")
  2. Under the "Command" column select the 'Toggle Breakpoint'. You can also use the shortcut key "B" from the keyboard.

Breakpoint & Start Point in Selenium IDE

When you toggle breakpoint, it will open another window as shown below. You will see two yellow pipes mark, in front of "clickandwait", under 'Command' column.

Breakpoint & Start Point in Selenium IDE

It indicates two things,

  • The yellow pipe shows that the test case was paused at that point. So when you click the 'Run' button, the execution starts from the beginning of the test case to this point. After that, one need to start executing manually.
  • A Test Script can have multiple breakpoints which can be set in the same manner as shown above.

Second Method:

Step 1) Follow the above steps 1, 2 & 3 mentioned in the First method.

Step 2) In this step,

  1. Click on option 'Actions' from Menu bar and
  2. Click on the option "Toggle Breakpoint".

Breakpoint & Start Point in Selenium IDE

This is all about the breakpoints in Selenium.

Start Point in Selenium

In Selenium, Start Point indicates the point from where the execution should begin. Start Point can be used when you want to run the testscript from the middle of the code or a breakpoint.

To understand this, let us take an example of the login scenario. Suppose, if you have to login into the website and perform series of tests and then try to debug one of those tests.

In this case, you have to login once and then re-run your tests as you are developing them. You can set the Start Points after login function. So everytime you perform a new test it will begin executing after the login function.

Start Point can be selected by two methods:

1. Right click on any command under the 'Command' column in selenium IDE. Select the option 'Set/clear Start Point '. You can also use the shortcut key 'S' from the keyboard to mark the start point (shown as a green triangle in the screen shot). Repeat the same step to deselect the Start Point .

2. Click "Actions" -> 'Set/Clear Start Point '. This will select the Start Point or repeat the same step to deselect them.

Methods to set Start Point in Selenium

Let see the first method with an example,

First Method:

Step 1) Launch Firefox and Selenium IDE.

Step 2) Type the Base URL as ---> http://newtours.demoaut.com/

Step 3) Click on the Record button (marked in red rectangle box in the the screen shot below).

Breakpoint & Start Point in Selenium IDE

Step 4) In this step,

  1. Under the tab "Table" right click on the command "clickandwait"
  2. Now select the option 'Set/Clear Start Point '. You can also use the short key "S" from the keyboard to select the same Set/Clear Start Point .

Breakpoint & Start Point in Selenium IDE

When you click on Set/ Clear Start Point, it will open another window. In this window, you can see the green Triangle symbol before "type" under 'Command' column.

This triangle symbol indicates that the test case starts at this point. So

when you click 'Run' button, the execution starts from that point onwards.

Breakpoint & Start Point in Selenium IDE

Note: There can only be one Start Point in a single test script. Also, Start Point is dependent on the currently displayed page. The execution will fail if the user is on the wrong page.

Second Method:

  1. Follow the above steps 1, 2 & 3 mentioned in previous (First) method.
  2. Next, follow the following steps,
  1. Click on option 'Actions' from Menu bar and
  2. Click on the option "Set/Clear Start Point ".

Breakpoint & Start Point in Selenium IDE

Summary

  • Breakpoints and Start Point feature help in the debugging process. It helps to start or pause any given test at a particular point of instance. This helps to observe the behavior of the test script.
  • In a single test script, there can only be one Start Point as compared to many Breakpoints.

This article is contributed by Rupa Nallani

posted on 2018-05-28 10:40  alicegu  阅读(355)  评论(0编辑  收藏  举报