-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d31d932
commit eabd466
Showing
7 changed files
with
271 additions
and
1 deletion.
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
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,65 @@ | ||
import test, { expect } from "@playwright/test"; | ||
import { WebHelper } from "../../../helper/web/webHelper"; | ||
|
||
test("Test 1 : Subscribe on dialog and call dismiss by clicking on Ok button", async ({ | ||
page, | ||
browser, | ||
}) => { | ||
const context = await browser.newContext(); | ||
const webHelper = new WebHelper(page, context); | ||
|
||
const expectedText = "I am JS Alert"; | ||
//setup listener to handle alert box | ||
webHelper.acceptAlertBox(); | ||
|
||
//write code to open alert box | ||
await webHelper.clickByText("click to open alert box"); | ||
|
||
//Assert | ||
expect(await webHelper.getAlertText()).toBe(expectedText); | ||
}); | ||
|
||
test("Test 2 : Subscribe on dialog and call accept by clicking on Ok button and dismiss by clicking on Cancel button", async ({ | ||
page, | ||
browser, | ||
}) => { | ||
const context = await browser.newContext(); | ||
const webHelper = new WebHelper(page, context); | ||
|
||
const expectedText = "I am JS Confirm box"; | ||
//setup listener to click on Ok button on confirm box | ||
webHelper.acceptConfirmBox(); | ||
|
||
//write code to open alert box | ||
await webHelper.clickByText("click to open Confirm box"); | ||
|
||
//Assert | ||
expect(await webHelper.getAlertText()).toBe(expectedText); | ||
|
||
//setup listener to click on Cancel button on confirm box | ||
webHelper.dismissConfirmBox(); | ||
|
||
//write code to open alert box | ||
await webHelper.clickByText("click to open Confirm box"); | ||
|
||
//Assert | ||
expect(await webHelper.getAlertText()).toBe(expectedText); | ||
}); | ||
|
||
test("Test 3 : Subscribe on Prompt, enter text in input box and call accept by clicking on Ok button", async ({ | ||
page, | ||
browser, | ||
}) => { | ||
const context = await browser.newContext(); | ||
const webHelper = new WebHelper(page, context); | ||
|
||
const expectedText = "I am JS Prompt box"; | ||
//setup listener to click on Ok button on confirm box | ||
webHelper.handlePromptBox(expectedText); | ||
|
||
//write code to open alert box | ||
await webHelper.clickByText("click to open Prompt box"); | ||
|
||
//Assert | ||
expect(await webHelper.getAlertText()).toBe(expectedText); | ||
}); |
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,27 @@ | ||
import { test, expect } from "@playwright/test"; | ||
import { WebHelper } from "../../../helper/web/webHelper"; | ||
import fs from "fs"; | ||
import path from "path"; | ||
|
||
test("File Download Test ", async ({ page, browser }) => { | ||
const context = await browser.newContext(); | ||
const webHelper = new WebHelper(page, context); | ||
|
||
//Arrange | ||
const expectedFileName = "fileToDownload.txt"; | ||
const downloadFolderPath = path.resolve(__dirname, "../test-data"); // path to the folder where the downloaded file will be saved | ||
const savePath = path.join(downloadFolderPath, expectedFileName); | ||
|
||
//Action | ||
await webHelper.downLoadFile( | ||
expectedFileName, | ||
downloadFolderPath, | ||
"locatorOfDownloadLink" | ||
); | ||
|
||
//Assert | ||
expect(fs.existsSync(savePath)).toBeTruthy(); | ||
|
||
//Clean up : remove downloaded file | ||
fs.unlinkSync(savePath); | ||
}); |
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,18 @@ | ||
import test, { expect } from "@playwright/test"; | ||
import { WebHelper } from "../../../helper/web/webHelper"; | ||
import path from "path"; | ||
|
||
test("File Upload Test ", async ({ page, browser }) => { | ||
const context = await browser.newContext(); | ||
const webHelper = new WebHelper(page, context); | ||
|
||
//Arrange | ||
const fileName = "uploadFile.txt"; | ||
const filePath = path.resolve(__dirname, `../test-data/${fileName}`); | ||
|
||
//Action | ||
await webHelper.uploadFile(fileName, filePath, "locatorOfUploadLink"); | ||
|
||
//Assert | ||
expect(await webHelper.elementHasText("locatorOfUploadLink", fileName)); | ||
}); |
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