Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      Sunshine And March Vibes (2025 Wallpapers Edition)

      May 16, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      May 16, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      May 16, 2025

      How To Prevent WordPress SQL Injection Attacks

      May 16, 2025

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025

      Minecraft licensing robbed us of this controversial NFL schedule release video

      May 16, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The power of generators

      May 16, 2025
      Recent

      The power of generators

      May 16, 2025

      Simplify Factory Associations with Laravel’s UseFactory Attribute

      May 16, 2025

      This Week in Laravel: React Native, PhpStorm Junie, and more

      May 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025
      Recent

      Microsoft has closed its “Experience Center” store in Sydney, Australia — as it ramps up a continued digital growth campaign

      May 16, 2025

      Bing Search APIs to be “decommissioned completely” as Microsoft urges developers to use its Azure agentic AI alternative

      May 16, 2025

      Microsoft might kill the Surface Laptop Studio as production is quietly halted

      May 16, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»Development»Screenshot not found error in protractor

    Screenshot not found error in protractor

    June 10, 2024

    I am getting broken image for screenshot. Unable to take screenshot in protractor framework. Please anyone help on this.

    My code:
    testconfig.js file

    var fs = require(‘fs-extra’);
    var today = new Date(),
    timeStamp = today.getMonth() + 1 + ‘-‘ + today.getDate() + ‘-‘ + today.getFullYear() + ‘-‘ + today.getHours() + ‘h-‘ + today.getMinutes() + ‘m’;
    console.log(timeStamp)

    exports.config = {
    directConnect: true,
    // seleniumAddress: ‘http://localhost:4444/wd/hub’,
    capabilities: {
    ‘browserName’: ‘chrome’,//firefox
    },

    suites: {
    regression: ‘../specs/sample.js’,

    },
    allScriptsTimeout: 50000,

    jasmineNodeOpts: {
    onComplete: null,
    isVerbose: false,
    showColors: true,
    includeStackTrace: true,
    defaultTimeoutInterval: 999999,
    },
    framework: ‘jasmine2’,

    onPrepare: function () {
    browser.manage().window().maximize();
    browser.waitForAngularEnabled(false);
    // var ChercherTechJasmineReporter = reporter.ChercherTechJasmineReporter;
    // jasmine.getEnv().addReporter(new ChercherTechJasmineReporter({
    // screenshotOnFail :false,
    // showSkipped:false,
    // browser:browser,
    // showLineChart:true
    // }));
    const SpecReporter = require(‘jasmine-spec-reporter’).SpecReporter;
    jasmine.getEnv().addReporter(new SpecReporter({
    spec: {
    // displayStacktrace: true
    displayStacktrace: false
    }
    }));
    //Getting XML report
    var jasmineReporters = require(‘jasmine-reporters’);
    jasmine.getEnv().addReporter(new jasmineReporters.JUnitXmlReporter({
    consolidateAll: true,
    filePrefix: ‘guitest-xmloutput’,
    savePath: ‘.’
    }));

    fs.emptyDir(‘/’, function (err) {
    console.log(“Error message=”,err);
    });

    jasmine.getEnv().addReporter({
    specDone: function(result) {
    // if (result.status == ‘failed’) {
    browser.getCapabilities().then(function (caps) {
    var browserName = caps.get(‘browserName’);
    browser.takeScreenshot().then(function (png) {
    // var stream = fs.createWriteStream(‘screenshots/’ + browserName + ‘-‘ + result.fullName+ ‘.png’);
    var stream = fs.createWriteStream(‘./’ + browserName + ‘-‘ + result.fullName+ ‘.png’);
    // var stream = fs.createWriteStream(‘./’ + ‘-‘ + result.fullName+ ‘.png’);
    stream.write(new Buffer(png, ‘base64’));
    stream.end();
    });
    });
    // }
    }
    });
    },
    // onComplete:function(exitcode){
    // reporter.write_consolidated()
    // },
    //
    // afterLaunch:function(exitcode){
    // return new Promise(function(resolve){
    // reporter.processResults()
    // return 0
    // })
    // },
    onComplete: function() {
    var browserName, browserVersion;
    var capsPromise = browser.getCapabilities();

    capsPromise.then(function (caps) {
    browserName = caps.get(‘browserName’);
    browserVersion = caps.get(‘version’);
    platform = caps.get(‘platform’);

    var HTMLReport = require(‘protractor-html-reporter-2’);

    testConfig = {
    reportTitle: ‘TAP Test Execution Report’,
    // outputPath: ‘./new/test/scripts/TestReports’,
    outputPath: ‘./’,
    outputFilename: ‘ProtractorTestReport’+timeStamp,
    screenshotPath: ‘./’,
    testBrowser: browserName,
    browserVersion: browserVersion,
    modifiedSuiteName: false,
    screenshotsOnlyOnFailure: false,
    testPlatform: platform
    };
    new HTMLReport().from(‘guitest-xmloutput.xml’, testConfig);
    });
    },

    SELENIUM_PROMISE_MANAGER: true
    };

    spec-sample.js file

    describe(‘Protractor – takeScreenshot()’, function () {
    it(‘Code script to use takeScreenshot() in protractor’, function () {
    browser.get(“https://keeplearners.blogspot.com/2018/03/Angular-elements.html”);
    var textField = element(by.model(‘name’));
    textField.sendKeys(“Entered sample text”)
    });
    } )

    output:

    Source: Read More

    Facebook Twitter Reddit Email Copy Link
    Previous ArticleTop 18 Visual Testing Tools for Testers (2024 Guide)
    Next Article How to understand the hits per second and active thread over time graphs in jmeter

    Related Posts

    Security

    Nmap 7.96 Launches with Lightning-Fast DNS and 612 Scripts

    May 16, 2025
    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-47916 – Invision Community Themeeditor Remote Code Execution

    May 16, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    CISA Warns of Exploitable Vulnerabilities in Popular BIND 9 DNS Software

    Development

    CVE-2025-4719 – Campcodes Sales and Inventory System SQL Injection Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    What’s New From MongoDB at AWS re:Invent 2024

    Databases

    Solution Highlight – Oracle Revenue Management / SSP – Part 1

    Development

    Highlights

    Development

    FBI and CISA Warn of BlackSuit Ransomware That Demands Up to $500 Million

    August 8, 2024

    The ransomware strain known as BlackSuit has demanded as much as $500 million in ransoms…

    CVE-2025-46755 – Apache HTTP Server SQL Injection

    April 29, 2025

    Seafile – file syncing and sharing

    December 7, 2024

    Microsoft Edge is eying another Fluent Design update on Windows 11

    December 31, 2024
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.