Comments (12)
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.
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.
Unfortunately, now it works only with protractor. I'll think how to implement custom screenshot.
from mochawesome-screenshots.
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.
Done. version 1.5.9
Use logReport.setScreenshot(this, imageFileName) to get custom screenshot at the report.
from mochawesome-screenshots.
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.
@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.
@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.
Done. version 1.5.9
Use logReport.setScreenshot(this, imageFileName) to get custom screenshot at the report.
How to receive logReport?
from mochawesome-screenshots.
require('mochawesome-screenshots/logReport');
from mochawesome-screenshots.
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.
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)
- Is there any option to enable-disable 'Show Code' and 'Show Log' options in HTML Report
- Error: Problem with mochawesome: ReferenceError: path is not defined HOT 1
- Screenshots not showing up in report because filenames are too long HOT 6
- Not Getting Step wise Report HOT 1
- How to change background color and font color of report? HOT 2
- mochawesome-screenshots cannot generate the correct report with mocha-parallel-tests
- Set multiple screenshots plus title HOT 1
- Feature Request: Option to capture HTML
- Screenshots are missing when used with nightwatchjs
- Gulp build not running
- mochawesome-screenshots not capturing screenshots HOT 2
- Does mochawesome-screenshots support selenium webdriver? if yes, how should it be configured using .mocharc.js config file? HOT 5
- Display and logging of "before" and "after" hooks.
- No screenshot saved in puppeteer
- Flag to view or hide test passed and failed in Reports
- Any plan for supporting playwright with mocha
- No log message - this may take long time to investigate why screenshots are not taken
- Custom src file name are not display anywhere in report
- Only one screenshot is present in report html - how to view all
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mochawesome-screenshots.