-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathalert.spec.js
27 lines (23 loc) · 972 Bytes
/
alert.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
const { suite } = require('selenium-webdriver/testing');
const { By, Browser, until } = require('selenium-webdriver');
const assert = require("node:assert");
suite(function (env) {
describe('Interactions - Alerts', function () {
let driver;
before(async function () {
driver = await env.builder().build();
});
after(async () => await driver.quit());
it('Should be able to getText from alert', async function () {
await driver.get('https://www.selenium.dev/selenium/web/alerts.html');
await driver.findElement(By.id("alert")).click();
await driver.wait(until.alertIsPresent());
let alert = await driver.switchTo().alert();
let alertText = await alert.getText();
// Verify
assert.equal(alertText, "cheese")
//Press the OK button
await alert.accept();
});
});
}, { browsers: [Browser.CHROME] });