Progress Bar Challenge
STOP
Danger zone, do not proceed unless you gave it your all!
Click me to view the code
js
const { test } = require('@playwright/test');
const { ProgressBarPage } = require('../models/progress-bar.model');
test('Stop progress bar at 75%', async ({ page }) => {
const progressBarPage = new ProgressBarPage(page)
await progressBarPage.navigateToProgressBarPage()
await progressBarPage.clickStartButtion()
while (await progressBarPage.getProgressBarPercent() !== "75%") {
console.log(`Currently at ${await progressBarPage.getProgressBarPercent()}`);
}
await progressBarPage.clickStopButtion()
});
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
js
exports.ProgressBarPage = class ProgressBarPage {
constructor(page) {
this.page = page
this.progressBarUrl = page.goto("/progressbar")
this.startButton = page.locator("#startButton")
this.stopButton = page.locator("#stopButton")
this.progressBarText = page.locator("#progressBar")
}
async navigateToProgressBarPage() {
await this.progressBarUrl
}
async clickStartButtion() {
await this.startButton.click()
}
async clickStopButtion() {
await this.stopButton.click()
}
async getProgressBarPercent() {
let currentPercent = this.progressBarText.innerText()
return currentPercent
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22