Closed ezwanharun closed 6 years ago
I noticed that afterScenario
hook doesn't contained results status value compared to afterSteps
as below:
status: 'passed'
This caused screenshot functionality for that specific scenario been taken several times if the test is been failed in the middle or beginning of the steps. Suggesting to add this config to afterScenario
.
"wdio-cucumber-framework": "^1.1.0",
is it correct? can you try to update to 2.0.0
I'm using 2.0.0
release
@BorisOsipov any update on this?
@ezwanharun no updates. feel free to investigate and propose a PR
Don't think this is an issue. Since cucumber 3 or 4 they changed the scenarioResult
, this should work
After((scenarioResult)=>{
if (scenarioResult.result.status === Status.FAILED) {
browser.saveScreenshot()
}
});
To check it just log the scenarioResult
@BorisOsipov and @ezwanharun
I've checked it and the scenarioResult
will return this
{
"sourceLocation": {
"uri": "test/cucumber/test.feature",
"line": 10
},
"pickle": {
"tags": [],
"name": "Click on Developer Guide",
"language": "en",
"locations": [
{
"line": 10,
"column": 3
}
],
"steps": [
{
"text": "I go on the website \"http://webdriver.io\"",
"arguments": [],
"locations": [
{
"line": 4,
"column": 11
}
]
},
{
"text": "I click on link \"=Developer Guide\"",
"arguments": [],
"locations": [
{
"line": 11,
"column": 10
}
]
},
{
"text": "should the title of the page be \"WebdriverIO - Developer Guide\"",
"arguments": [],
"locations": [
{
"line": 12,
"column": 10
}
]
}
]
},
"result": {
"duration": 978,
"status": "passed"
}
}
Meaning you need to check scenarioResult.result.status
to get the status. This was for as far I can see a breaking change in CucumberJS 3, so not an issue in this wdio-cucumber-framework
and thus this issue could be closed
@wswebcreation Thanks for your help in investigating this issue!
Hi all, Currently I tried to taking a screenshots if my test was failed. However the afterScenario hook seem like doesn't able to identify which test is failed and passed. Below was my dependencies that I used:
afterScenario: function afterScenario(results) { if (results.status === "failed") { browser.saveScreenshot("./allure-results/"); } },