-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from jueluddinsf/cucumber-testLogin.feature/-cr…
…eated/--lahul testLogIn.feature/created/lahul
- Loading branch information
Showing
5 changed files
with
72 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/' | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}) |