How to start with Selenium Debugging

On This Page Debugging in SeleniumBreakpoints in SeleniumJune 24, 2026 · 4 min read · Tool Comparison

How to start with Selenium Debugging

Debugging is a critical part of automation quiz with Selenium. It helps testers hint failure, analyze control flowing, and identify the root cause of issues in test scripts. By leveraging the correct debugging techniques—such as breakpoints, screenshots, session logs, and testing on real devices—QA team can make their Selenium tests more reliable and easier to preserve.

Overview

What is Selenium Debugging?

  • Process of dissect tryout failures, understanding performance stream, and finding theme causes.
  • Essential for testers to work effectively with declamatory automation frameworks.

How Do Breakpoints Help in Selenium Debugging?

  • Breakpoints halt execution at specific lines for step-by-step analysis.
  • Options: Step Over (F6), Step Into, and Resume (F8).
  • Variables tab shows real-time value changes during execution.

How Can Screenshots Support Debugging?

  • Selenium supply TakesScreenshot interface for capturing UI states.
  • Screenshots reveal trial procession and UI conditions at failure points.

This clause explainshow to debug Selenium exam using breakpoints, screenshots, session logging, and real devicefor faster issue firmness and authentic test outcomes.

Debugging in Selenium

There are multiple manner to debug Selenium code.

  1. Applying breakpoints
  2. Screenshots
  3. Session Logging

Breakpoints in Selenium

Let ’ s initiatory understand what breakpoints are and how to use them while debugging.

in automation quiz assist us to halt execution at a particular point in our code. When you use a breakpoint at some point in our code, it facilitate debug the code step by step from that point.

Let us see how to apply breakpoints and run our code in debug way:

Pro tip: Tools like SUSA can handle this autonomously — upload your app and get results without writing a single test script.

Step 1Place the cursor on the line where you want to apply the breakpoint and pressCtrl+Shift+B. You can also double-click on the left-hand side of the editor window.

Here you can see the breakpoint is use in line number 50.

Step 2You can place the breakpoint by navigating and takeRun & gt; Toggle Breakpointin the Eclipse editor.

Step 3After applying the breakpoint, you can now accomplish the code in debug mode by selectingRun & gt; Debug As & gt; TestNGtest. Using TestNG in this example.

You can also right-click anywhere in the broadcast and invoke theDebug as option.

Also Read:

Step 4After invoking the debug option, your code will start fulfil in debug way, and execution will halt at the breakpoint you apply at line 50.

As you can see, the executing has halted at line 50, and it is highlighted in green. The breakpoints tab that is displayed at the correct hand side of the image shows all the breakpoints applied.

Step 5There is another “ variables ” tab that expose the values delegate to the variables during execution. You can also see the variable values changing as the executing stream depart from one line to another.

Step 6Once the control has reached up to the breakpoint, You can execute a piece of codification or method as a whole (not executing it step by pace) by pressing F6 or Step over icon.

Step 7 You can also use the Step Into option to debug the code line by line.

Step 8You can stop the step-by-step executing and resume normal execution by pressingF8 or Resume.

Capturing Screenshots

help us to understand how the test performance has progressed during the execution of test scripts. Selenium let us to take screenshots during the execution of test scripts with the assistant of an interface ringTakeScreenshot.

Must Read:

Let ’ s see how to use this interface with the help of the below example:

package screenshotsinselenium; import java.io.File; import org.apache.commons.io.FileUtils; meaning org.openqa.selenium.OutputType; import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; import org.testng.annotations.Test; public grade screenshotsexample {@ Test public nihility testBStackTakeScreenShot () throws Exception {WebDriver driver; System.setProperty (`` webdriver.chrome.driver '', '' c: \\chromedriver.exe ''); driver = new ChromeDriver (); driver.get (`` https: //www.browserstack.com ''); //calling the screenshot function this.takeScreenShot (driver, `` D: //BSTest.png '');} public static void takeScreenShot (WebDriver webdriver, String fileWithPath) shed Exception {//1. We need to convert webdriver object to TakeScreenshot TakesScreenshot scrShot = ((TakesScreenshot) webdriver); //2. Calling the method getScreenshotAs and specify the output type of screenshot. File SourceFile=scrShot.getScreenshotAs (OutputType.FILE); //3. Then displace the screenshot to the finish path where we ask to copy our file File DestinationFile=new File (fileWithPath); //4. simulate the file FileUtils.copyFile (SourceFile, DestinationFile);}}

Session Logging

As the automation suite grows in size, the number of failures also may grow, and hence it becomes difficult to debug these failure or monitor the entire test execution. At this point, session recording can help us to enter the entire session of executing and save it for future reference. Session recording helps to record the blind states, screen transitions during execution, inputs to different tests, etc.

This might help for a detailed understanding of execution flowing and locate exact point of failures. These transcription can also be given as execution evidence to developer and other stakeholders. Selenium perform not provide direct support for session recording, but you can integrate it with a third-party instrument called Monte Media Library.

Debugging on Real Devices

Debugging on real device helps to interpret and debug the covering & # 8217; s behaviour in. BrowserStack offers a platform. You can access over 3000+ different device, browser, and OS combinations using this program. There are different use cases when the test results alter in dev environment and in real user conditions, which is why it is recommended to prove on real devices for accurate test answer.

It facilitate deliver seamless and coherent exploiter experience across different device-browser-OS combinations under real world weather. You can run same tests on multiple device-browser combinations saving clip and.

Tags
23,000+ Views

# Ask-and-Contributeabout this topic with our Discord community.

Related Guides

Automate This With SUSA

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts needed.

Try SUSA Free

Test Your App Autonomously

Upload your APK or URL. SUSA explores like 10 real users — finds bugs, accessibility violations, and security issues. No scripts.

Try SUSA Free