Skip to content

Commit

Permalink
add code to the hook so it can actually save a screenshot on error & …
Browse files Browse the repository at this point in the history
…create a 2nd feature file
  • Loading branch information
Cristi-Fogel committed Dec 6, 2024
1 parent 442403f commit 48b5466
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
14 changes: 14 additions & 0 deletions features/ErrorValidations.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: Ecommerce2 validations

Scenario: Placing the Order
Given a login to Ecommerce2 application with "[email protected]" and "Password1"
Then Verify Error Message is displayed

# await page.goto("https://rahulshettyacademy.com/loginpagePractise/");
# await userNameInput.fill("rahulshe");
# await page.locator("[type='password']").fill("learning");
# await signInButton.click();
# # //no explicit wait needed like selenium (takes one from config 30s)
# console.log(await page.locator("[style*='block']").textContent()); // grab text
# await expect(page.locator("[style*='block']")).toContainText('Incorrect'); //no need to have all text, just one word in this case

8 changes: 5 additions & 3 deletions features/support/hooks.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const playwright = require('playwright/test');
const { POManager } = require("../../pageObjects/POManager");
const { Before, After } = require ('@cucumber/cucumber');
const { Before, After, BeforeStep, AfterStep, Status } = require ('@cucumber/cucumber');


Before(async function() {
Expand All @@ -16,8 +16,10 @@ Before(async function() {
BeforeStep(function(){

});
AfterStep(function({result}){

AfterStep(async function({result}){
if(result.status === Status.FAILED){
await this.page.screenshot({path: 'screenshot1.png'});
}
});

After (function(){
Expand Down

0 comments on commit 48b5466

Please sign in to comment.