Debugging Protractor Tests for Selenium Test Automation.

Debugging Protractor tests helps you quickly find and fix issues in Selenium end-to-end testing so your tests run reliably across browsers and systems.

Table of Contents

Share

<Summary/>

  • Debugging helps identify test, browser, or framework failures.

  • Common failures include expectation, WebDriver, Angular, and timeout errors.

  • Pause method lets you inspect test execution step by step.

  • Screenshot method captures visual proof of failures.

  • Choosing the right debugging method saves time and effort.

Debugging is a process to make sure that your tests run in the desired manner. So let us see our ways to help you debug Protractor tests.

End-to-end testing is essential for applications to ensure their quality. This guarantees bugs and problems. Step-by-step debugging is the way to solve any bug that comes up when testing any application. Selenium automation tests are essential to check if a test run goes as expected.

Here, we will tell you how to debug protractor tests for Selenium test automation. However, before we dive into debugging, let us see some stuff related to debugging.

Problems during Debugging Protractor Tests

Bugs come up during the testing of any application. This might be due to a module problem or some compatibility issues. The problems or bugs that come up during debugging can be:

  • Testing is tricky because it is dependent on the entire system.

  • Different operating systems and browsers necessitate the use of different WebDrivers for cross-platform testing.

  • Selenium test scenarios consist of a linked series of sequences that are dependent on the previous outcome, thus the dependency.

  • Sometimes the error messages are very lengthy, hence tough to understand.

  • Distinguishing between compatibility issues and application issues is a tough nut to crack.

Types of Failure to debug in protractor tests

While testing, there are some major types of failures to be encountered. These failure scenarios are:

  • Expectation Failure

  • WebDriver Failure

  • WebDriver Unexpected Failure

  • Protractor Angular Failure

  • Protractor Timeout Failure

Expectation Failure

Failure during normal flow execution is one of the most common test failures. Expected failure is a result of this.

WebDriver Failure

When a browser requests an element and it is missing, it causes a WebDriver Failure error. This means that there is a failure in executing the requested command.

WebDriver Unexpected Failure

In a situation where the web driver update fails, the browser or OS crashes. This is an instance of WebDriver's Unexpected Failure.

Protractor Angular Failure

When the Protractor Framework is not able to find the required Angular libraries in the module, it coins the error Protractor Angular Failure.

Protractor Timeout Failure

In a situation where the test suite is stuck in a time loop for an extended period, the data is not returned; this calls for a Protractor Timeout Failure.

Debugging Protractor Tests in Selenium

Protractor can extend the functionality of the node debugger, which is used by the majority of node js apps.This allows you to add additional statements needed in debugging mode from the terminal while debugging.

There are multiple debug Protractor tests. These are:

  • Pause Method

  • Debugger Method

  • Screen Shot Method

We have explained these methods here,

Pause Method to Debug Tests

The pause method is the easiest and most popular way to debug Protractor tests. This test is run by inserting the browser—pause () method at the point where we want to pause the test and check for errors. The script for this method is executed using:

$ protractor test_config.js

When this code is used and executed, whenever we press the pause key, we see intervals of runtime. We can use this method to check specific code intervals. If a particular interval is not executed, then we can find the error in that particular interval. We don’t need to see the entire code for that error. Hence, this method is straightforward yet efficient.


// test_debug.js //// describing our test scenario for protractor framework //describe(‘ Sample Protractor Test Suite for debugging example ‘,function(){// information about the test case it(‘An Example to perform Debug during Testing’,function(){// launching the url in browser // browser.get(“http://www.google.com”); browser.pause(); element(by.model(‘testName’)).sendKeys(‘Test Automation’); // It performs the check whether the element exist or not // var myText = element(by.binding(‘myTestString’)).getText(); expect(‘Welcome to ‘+myText+’!’).toEqual(‘Welcome to Test Automation!’) });});

Screenshot Method

Screenshots. This method may sound weird, but yes, it still exists as a method. It is a rather exciting way of debugging. Selenium WebDriver can be programmed to take a screenshot using the browser.takeScreenshot(). This is a rather standard method on servers that are used continuously to run tests.

This test results in a screenshot in PNG format with base64 encoding.


// test_debug.js //// the variable declared at the beginning of the test script:var myscript = require(‘fs’);// function that defines how to write screenshot to a filefunction writeScreenShot(data, filename) { var mystream = myscript.createWriteStream(filename); mystream.write(new Buffer(data, ‘base64’)); mystream.end();}// describing our test scenario for protractor framework //describe(‘ Sample Protractor Test Suite for debugging example ‘,function(){// information about the test case it(‘An Example to perform Debug during Testing’,function(){// launching the url in browser // browser.get(“http://www.google.com”); browser.takeScreenshot().then(function (png) { writeScreenShot(png, ‘exception.png’);}); element(by.model(‘testName’)).sendKeys(‘Test Automation’); // It performs the check whether the element exist or not // var myText = element(by.binding(‘myTestString’)).getText(); expect(‘Welcome to ‘+myText+’!’).toEqual(‘Welcome to Test Automation!’) });});

Online Selenium Testing

These above methods can be executed on an online server that supports Selenium as well.

For this, we just need minimal changes in the code, and it works fine. LambdaTest Hub is the perfect place for this thing.


// test_config.js

// This file serves as a configuration file for our test case

// LambdaTest Credentials

LT_USERNAME = process.env.LT_USERNAME || "irohitgoyal";

LT_ACCESS_KEY =

process.env.LT_ACCESS_KEY ||

"r9JhziRaOvd5T4KCJ9ac4fPXEVYlOTealBrADuhdkhbiqVGdBg";

// LambdaTest Capabilities

exports.capabilities = {

build: "Automation Selenium Webdriver Test Script", // Build name displayed in test logs

name: "Protractor Selenium Debugging Test on Chrome", // Test name

// platform: "Windows 10", // Operating System

browserName: "chrome", // Browser name

version: "79.0", // Browser version

visual: false, // Capture step-by-step screenshots

network: false, // Capture network logs

console: false, // Capture console logs

tunnel: false // Enable LambdaTest tunnel for localhost testing

};

// Protractor Configuration

exports.config = {

directConnect: true,

// Desired capabilities passed to the WebDriver instance

capabilities: {

browserName: "chrome"

},

// Test framework

framework: "jasmine",

// Test specs

specs: ["test_debug.js"],

// Timeout settings

allScriptsTimeout: 999999,

jasmineNodeOpts: {

defaultTimeoutInterval: 999999

},

// Preparation before tests run

onPrepare: function () {

browser.manage().window().maximize();

browser.manage().timeouts().implicitlyWait(5000);

}

};


Conclusion

We will conclude the Protractor testing guide here. These are the methods that we employ in order to test a Selenium application while it is being debugged. Not all the methods would be suitable for your work type and requirements.

So experiment to see which method best suits your line of work.

Have a Worthy Debugging!

Why choose PerfectQA services

At PerfectQA, automation is not just about speed — it’s about assurance. We combine framework expertise, proactive analysis, and audit-driven reporting to deliver testing solutions that scale with your business

Expertise and Experience: 15+ years in automation and regression testing across multiple industries

Customised Frameworks: We adapt to your tech stack, not the other way around.

State-of-the-Art Tools: Selenium, Playwright, Cypress, and CI/CD integrations.

Proactive Support: Continuous improvement through audit and debugging

About PerfectQA

PerfectQA is a global QA and automation testing company helping businesses maintain flawless software performance through manual, automated, and hybrid testing frameworks

Our mission

Deliver precision, speed, and trust with every test cycle

Learn more about our solutions

Want flawless automation?

Schedule your free test strategy consultation today and see how PerfectQA can help you achieve continuous quality at scale

Published

Nov 22, 2023

Updated

Author

Rahul Sharma

©2026 PerefectQA LLP | All rights reserved

Privacy

·

Terms

·

Cookies