Skip to content

Commit

Permalink
Merge pull request #6 from jueluddinsf/cucumber-testLogin.feature/-cr…
Browse files Browse the repository at this point in the history
…eated/--lahul

testLogIn.feature/created/lahul
  • Loading branch information
PrinceSoni83 authored Mar 11, 2024
2 parents 99a9df4 + bc88b82 commit 12f7ca7
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 3 deletions.
2 changes: 1 addition & 1 deletion config/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Object.assign(global, {
BASE_URL: 'https://www.saucedemo.com'
BASE_URL: 'https://practicetestautomation.com/practice-test-login/'
});
14 changes: 14 additions & 0 deletions features/testlogin.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Feature: Test Login Page


As a test login user
I want to be able to log in to my account
All basic scenarios for login Page



Scenario: I should be able to test login
Given I am on the test login screen
Then I fill the test login form with valid credentials
And Then I should be able to see the home page

39 changes: 39 additions & 0 deletions page-objects/test-login-page.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
locators = {
"username_input": "#user-name",
"password_input": "#password",
"login_button": "#login-button",
"inventory_container": "#inventory_container" ,

}

class TestLoginPage {

async navigateToTestLoginPage() {
return await page.goto(global.BASE_URL);
}

async verifyTestLoginPageIsDisplayed() {
return expect(await page.title()).to.equal('Test Login | Practice Test Automation');
}


async submitTestLoginForm() {
const element = await page.waitForSelector(locators.username_input);
await page.fill(locators.username_input,'student');
await page.fill(locators.password_input,'Password123');
await page.click(locators.login_button);
}

async verifyAfterTestLoginPage() {
await page.waitForSelector(locators.inventory_container);
const visible = await page.isVisible(locators.inventory_container);
return expect(visible).to.equal(true);

}

}

module.exports = { TestLoginPage };



4 changes: 2 additions & 2 deletions setup/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ const cucumber = require('../cucumber');

// Launch options.
const options = {
headless: true,
headless: false,
slowMo: 100
};

// Create a global browser for the test session.
BeforeAll(async () => {
console.log('before all ...');
global.browser = await playwright['firefox'].launch(options);
global.browser = await playwright['chromium'].launch(options);
});

AfterAll(async () => {
Expand Down
16 changes: 16 additions & 0 deletions step-definitions/test-login-step.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const { Given, When , Then } = require('@cucumber/cucumber');
const { TestLoginPage } = require('../page-objects/test-login-page');
const testLoginPage = new TestLoginPage();

Given('I am on the test login screen', async function() {
await testLoginPage.navigateToTestLoginPage();
await testLoginPage.verifyTestLoginPageIsDisplayed();
});

When('I fill the test login form with valid credentials', async function() {
await testLoginPage.submitTestLoginForm();
});

Then('Then I should be able to see the home page', async function() {
await testLoginPage.verifyAfterTestLoginPage();
})

0 comments on commit 12f7ca7

Please sign in to comment.