Giter VIP home page Giter VIP logo

Comments (12)

BelAn97 avatar BelAn97 commented on July 17, 2024

Screenshorts for failed tests generate automatically using protractor.browser.takeScreenshot() method.
For passed tests you need add 'takePassedScreenshot' parameter to mocha options:
--reporter-options takePassedScreenshot=true

from mochawesome-screenshots.

sumeetp4 avatar sumeetp4 commented on July 17, 2024

What if I'm using mocha, and for me client.screenshot() function returns the screenshot or I can client.saveScreenshot() to save it in some location

from mochawesome-screenshots.

BelAn97 avatar BelAn97 commented on July 17, 2024

Unfortunately, now it works only with protractor. I'll think how to implement custom screenshot.

from mochawesome-screenshots.

sumeetp4 avatar sumeetp4 commented on July 17, 2024

Okay so what I did is
in my test I have added afterEach in my js file to execute it after each test case and take a screenshot for failed and save it in screenshots location

afterEach("take screenshot on failure", function() {
if (this.currentTest.state !== "passed") {
var imageFileName = this.currentTest.title+'.jpeg';
client.saveScreenshot('./mochawesome-reports/screenshots/'+imageFileName);
}
});

Also updated mochawesome.js to take the same name
Working for now 💯

from mochawesome-screenshots.

BelAn97 avatar BelAn97 commented on July 17, 2024

Done. version 1.5.9
Use logReport.setScreenshot(this, imageFileName) to get custom screenshot at the report.

from mochawesome-screenshots.

AndrewFisher093 avatar AndrewFisher093 commented on July 17, 2024

Hello
I'm using mocha as framework and mochawesome as a reporter in my automation project. How can I use mochawesome-screenshots without protractor methods and config files?
Example of my console command which launching tests:
mocha tests --reporter mochawesome --reporter-options autoOpen=true --browser Chrome

Thx for the reply

from mochawesome-screenshots.

linjin-harvey avatar linjin-harvey commented on July 17, 2024

@AndrewFisher093 You can use it directly, my test run by below command:
mocha ./test/spec//.js --reporter mochawesome-screenshots --reporter-options jsonReport=true,clearOldScreenshots=true,shortScrFileNames=true --timeout=60000

from mochawesome-screenshots.

anilchander1 avatar anilchander1 commented on July 17, 2024

@BelAn97 logReport.setScreenshot(this, imageFileName) , will imageFileName accept a file name with a relative or absolute path or is it just a name? I am not able to see the screenshot in the report when my test is in the test folder and the screenshot is generated is one level up in ./mochawesome-reports/screenshots/ folder.

from mochawesome-screenshots.

Serg-develop avatar Serg-develop commented on July 17, 2024

Done. version 1.5.9
Use logReport.setScreenshot(this, imageFileName) to get custom screenshot at the report.
How to receive logReport?

from mochawesome-screenshots.

BelAn97 avatar BelAn97 commented on July 17, 2024

require('mochawesome-screenshots/logReport');

from mochawesome-screenshots.

Serg-develop avatar Serg-develop commented on July 17, 2024

Can i use this functionality without Protector?
I see, that someone up this topic above, but i didn`t understand well.

Thanks.

from mochawesome-screenshots.

BelAn97 avatar BelAn97 commented on July 17, 2024

it uses default protractor's browser.takeScreenshot() method, but if you do not have browser object - this will skip.

from mochawesome-screenshots.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.