package stepDefinitions; import framework.Framework; import com.microsoft.playwright.Page; import helpers.LoginPage; import io.cucumber.java.Scenario; import io.cucumber.java.en.Given; import io.cucumber.java.en.Then; import io.cucumber.java.en.When; import org.junit.Assert; import static configuration.data.Login.*; public class LoginSteps { private LoginPage login; private final Page page = Framework.getPage(); private final Scenario scenario = Framework.getScenario(); @Given("User launched SwagLabs application") public void userLaunchedSwagLabsApplication() { login = new LoginPage(page); page.navigate(URL); } @When("User verify the Page title") public void verifyPageTitle() { String title = login.verifyTitle(); Assert.assertEquals(title, SWAG_LABS); scenario.attach(SWAG_LABS, "text/plain", "title verified"); } @When("User verify the Page title with wrong title") public void verifyPageTitleWrongly() { String title = login.verifyTitle(); scenario.attach(WRONG_TITLE, "text/plain", "title verified"); Assert.assertEquals(title, WRONG_TITLE); } @When("User logged in the app using username and password") public void loginIntoTheApplication() { login.loginIntoApplication(USERNAME, PASSWORD); } @When("User logged in the app using username {string} and password {string}") public void loginIntoTheApplicationWrongWay(String username, String password) { login.loginIntoApplication(username, password); } @Then("User logout from the application") public void logoutFromApplication() { login.logoutApplication(); } }