-
Notifications
You must be signed in to change notification settings - Fork 1
/
demoAut.js
47 lines (38 loc) · 1.4 KB
/
demoAut.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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const puppeteer = require('puppeteer');
const config = {
launchOptions: {
headless: false
},
viewport:{width:1920, height:1080}
}
//locators
const registrationPage = {
firstname: 'input[name="firstName"]',
lastname: 'input[name="lastName"]',
username: 'input[name="email"]',
password: 'input[name="password"]',
confirmPassword: 'input[name="confirmPassword"]',
submit: 'input[name="register"]'
}
const registrationConfirmation = {
sigin: 'a[href="mercurysignon.php"]'
}
puppeteer.launch(config.launchOptions).then(async browser => {
const page = await browser.newPage();
await page.setViewport(config.viewport)
//mercury tours registration page
await page.goto('http://newtours.demoaut.com/mercuryregister.php');
//wait for the firstname to appear
await page.waitFor(registrationPage.firstname);
//enter the details
await page.type(registrationPage.firstname, 'firstName');
await page.type(registrationPage.lastname, 'lastName');
await page.type(registrationPage.username, 'test');
await page.type(registrationPage.password, 'password');
await page.type(registrationPage.confirmPassword, 'password');
await page.click(registrationPage.submit);
//after page submission check for the sign-in confirmation
await page.waitFor(registrationConfirmation.sigin);
await page.click(registrationConfirmation.sigin);
await browser.close();
});