Skip to content

Commit

Permalink
testers talk
Browse files Browse the repository at this point in the history
  • Loading branch information
BakkappaN committed Aug 26, 2024
1 parent 57f0c8c commit 3bdf249
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 57 deletions.
7 changes: 5 additions & 2 deletions pages/resultpage.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
// Inlcude playwright module
const { expect } = require('@playwright/test')

import BaseTest from '../utils/basetest';

// create class
exports.ResultPage = class ResultPage {

/**
*
* @param {import ('@playwright/test').Page} page
*/
constructor(page){
const baseTest = new BaseTest(page);

// Init page object
this.page = page;

// Elements
this.playlistlink = page.getByRole('link',{name:'Playwright by Testers Talk'});
this.playlistlink = page.getByRole('link',{name: baseTest.testData.module1.skill1 });
}

async clickOnPlaylist(){
Expand Down
14 changes: 2 additions & 12 deletions test-data/qa/google.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,6 @@
{
"Module1TestData": {
"skill1": "playwright by testers talk",
"skill2": "cypress by testers talk",
"skill3": "javascript by testers talk",
"skill4": "postman by testers talk",
"skill5": "rest assured by testers talk",
"skill6": "specflow by testers talk",
"skill7": "easyrepro by testers talk",
"skill8": "api testing by testers talk"
},
"qaTestData": {
"skill1": "playwright by testers talk",
"module1": {
"skill1": "Playwright by Testers Talk",
"skill2": "cypress by testers talk",
"skill3": "javascript by testers talk",
"skill4": "postman by testers talk",
Expand Down
28 changes: 9 additions & 19 deletions test-data/stage/google.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,12 @@
{
"Module1TestData":{
"skill1":"playwright by testers talk",
"skill2":"cypress by testers talk",
"skill3":"javascript by testers talk",
"skill4":"postman by testers talk",
"skill5":"rest assured by testers talk",
"skill6":"specflow by testers talk",
"skill7":"easyrepro by testers talk",
"skill8":"api testing by testers talk"
},
"stageTestData":{
"skill1":"cypress by testers talk",
"skill2":"playwright by testers talk",
"skill3":"javascript by testers talk",
"skill4":"postman by testers talk",
"skill5":"rest assured by testers talk",
"skill6":"specflow by testers talk",
"skill7":"easyrepro by testers talk",
"skill8":"api testing by testers talk"
"module1": {
"skill1": "Cypress by Testers Talk",
"skill2": "playwright by testers talk",
"skill3": "javascript by testers talk",
"skill4": "postman by testers talk",
"skill5": "rest assured by testers talk",
"skill6": "specflow by testers talk",
"skill7": "easyrepro by testers talk",
"skill8": "api testing by testers talk"
}
}
15 changes: 1 addition & 14 deletions tests/parabank.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,11 @@ const { OpenNewAccountPage } = require('../pages/opennewaccountpage');

import { pbanktestdata } from "../test-data/qa/parabank.json";
import { runtimetestdata } from '../test-data/runtimetestdata.json'
import { qaTestData } from "../test-data/qa/google.json";
import { stageTestData } from "../test-data/stage/google.json";
import { faker } from "@faker-js/faker";

import { updateJsonFile } from '../utils/helper';

const filePath = path.join(__dirname, "../test-data/runtimetestdata.json");

let testData = null;

test.beforeAll('Running before all tests', () => {
if (process.env.ENV == 'qa') {
testData = qaTestData;
} else {
testData = stageTestData;
}
})

/**
* Bakkappa N
*/
Expand Down Expand Up @@ -78,7 +65,7 @@ test('Verify that user is able to login successfully in the ParaBank application
});

await test.step('Login into application', async () => {
await loginPage.loginToApplication();
await loginPage.loginToApplication(runtimetestdata.username, pbanktestdata.password);
});

await test.step('Verify that user is able to login successfully', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/uitest.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test('UI automation test using playwright', { tag: '@UITest' }, async ({ page })
});

await test.step('Search with keywords', async () => {
await homepage.searchKeywords(baseTest.testData.skill1);
await homepage.searchKeywords(baseTest.testData.module1.skill1);
});

await test.step('Click on playlist', async () => {
Expand Down
28 changes: 19 additions & 9 deletions utils/basetest.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,42 @@
// Inlcude playwright module
const { test, expect } = require('@playwright/test');
const fs = require('fs');

import { qaTestData } from "../test-data/qa/google.json";
import { stageTestData } from "../test-data/stage/google.json";
// import { qaTestData } from "../test-data/qa/google.json";
// import { stageTestData } from "../test-data/stage/google.json";

/**
* Bakkappa N
*/
class BaseTest {

/**
*
* @param {import ('@playwright/test').Page} page
*/
constructor(page) {

// Init page object
this.page = page;

if (process.env.ENV == 'qa') {
this.testData = qaTestData;
} else {
this.testData = stageTestData;
}
// Get test data
const environment = process.env.TEST_ENV || 'qa';
const testDataFile = `./test-data/${environment}/google.json`;
this.testData = JSON.parse(fs.readFileSync(testDataFile, 'utf8'));

// if (process.env.ENV == 'qa') {
// this.testData = qaTestData;
// } else {
// this.testData = stageTestData;
// }
}

async goto() {
await this.page.setViewportSize({ width: 1366, height: 728 })
await this.page.goto('https://www.google.com');
if (process.env.TEST_ENV == 'qa') {
await this.page.goto('https://www.google.com');
} else {
await this.page.goto('https://www.google.com');
}
}
}
export default BaseTest;

0 comments on commit 3bdf249

Please sign in to comment.