Skip to content

Commit

Permalink
added simple test case
Browse files Browse the repository at this point in the history
  • Loading branch information
Mahbub091 committed Mar 25, 2023
1 parent 974becf commit 2ceeaf3
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 41 deletions.
9 changes: 9 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"compilerOptions": {
"types": [
"node",
"@wdio/globals/types",
"@wdio/mocha-framework"
]
}
}
3 changes: 3 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 14 additions & 2 deletions test/e2e/homepage.e2e.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
import LoginPage from '../pageobjects/login.page.js';
import SecurePage from '../pageobjects/secure.page.js';


describe('Validating HomePage', () => {
it('Navigating to the URL', async () => {
await LoginPage.open()
await expect(browser).toHaveUrl("https://ecommerce-playground.lambdatest.io/login")
await expect(browser).toHaveTitle("Your Store")
await expect(LoginPage.searchBar).toBeDisplayed()
});

it('Validating & Using Search Box',async () => {
await expect(LoginPage.searchBar).toBeDisplayed()
await LoginPage.searchingForDesiredProduct("Apple")
});

it('My Account Button',async () => {
await expect(LoginPage.myAccountButton).toBeDisplayed()
await (await LoginPage.myAccountButton).click()
expect (browser).toHaveUrl("https://ecommerce-playground.lambdatest.io/index.php?route=account/login")
});
});
35 changes: 20 additions & 15 deletions test/pageobjects/login.page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,37 +6,42 @@ import Page from '../pageobjects/page.js';
* sub page containing specific selectors and methods for a specific page
*/
class LoginPage extends Page {

/**
* overwrite specific options to adapt it to page object
*/
open () {
return super.open('login');
}

/**
* define selectors using getter methods
*/
get inputUsername () {
return $('#username');
get searchBar () {
return $("#entry_217820 [type='text']")
}

get inputPassword () {
return $('#password');
get btnSubmit () {
return $("div#search .type-text");
}

get btnSubmit () {
return $('button[type="submit"]');
get myAccountButton() {
return $("div#widget-navbar-217834 > ul > li:nth-of-type(6) > a[role='button'] .title")
}

/**
* a method to encapsule automation code to interact with the page
* e.g. to login using username and password
*/
async login (username, password) {
await this.inputUsername.setValue(username);
await this.inputPassword.setValue(password);

async searchingForDesiredProduct (searchText) {
await this.searchBar.setValue(searchText);
await this.btnSubmit.click();
}

/**
* overwrite specific options to adapt it to page object
*/
open () {
return super.open('login');
}



}

export default new LoginPage();
9 changes: 4 additions & 5 deletions test/specs/ui/example.e2e.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import LoginPage from '../../pageobjects/login.page';
import SecurePage from '../../pageobjects/secure.page';

describe('My Login application', () => {
it('should login with valid credentials', async () => {
await LoginPage.open();

// await LoginPage.login('tomsmith', 'SuperSecretPassword!');
// await expect(SecurePage.flashAlert).toBeExisting();
// await expect(SecurePage.flashAlert).toHaveTextContaining(
// 'You logged into a secure area!');
await LoginPage.login('tomsmith', 'SuperSecretPassword!');
await expect(SecurePage.flashAlert).toBeExisting();
await expect(SecurePage.flashAlert).toHaveTextContaining(
'You logged into a secure area!');
});
});

Expand Down
19 changes: 0 additions & 19 deletions test/specs/ui/sampleTest.e2e.js

This file was deleted.

0 comments on commit 2ceeaf3

Please sign in to comment.