Created
September 6, 2019 10:00
-
-
Save morena/c4f0ed280079665bceb3f877567652f4 to your computer and use it in GitHub Desktop.
JS Bin // source https://jsbin.com/nujucol
This file contains hidden or 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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
<script id="jsbin-javascript"> | |
//https://codeburst.io/a-guide-to-automating-scraping-the-web-with-javascript-chrome-puppeteer-node-js-b18efb9e9921 | |
const puppeteer = require('puppeteer'); | |
async function doSasjourney() { | |
const browser = await puppeteer.launch({ | |
headless: false, | |
args: ['--start-fullscreen','--window-size=1920,1040'] | |
}); | |
const page = await browser.newPage(); | |
await page.setViewport({ width: 1920, height: 1040 }); | |
await page.goto('http://gb-en.specsavers.local/book/halifax/appointment-type'); | |
//await puppeteer.launch({ devtools: true }); | |
//hide buttons | |
await page.click('#sliding-popup .agree-button') | |
await page.click('.hide-button'); | |
await page.waitFor(2000); | |
//select appointment | |
await page.click('.adult-eye-test--icon .appointment-type--book'); | |
//calendar page loads | |
await page.waitFor('.calendar-ab--slots__slot'); | |
//click on calendar day | |
await page.click('.calendar-ab--slots__slot:last-child'); | |
await page.click('.calendar-ab--book') | |
//customer details page loads | |
await page.waitFor('#customerEmail'); | |
//fill in customer details | |
await page.select('.ss-dyanimic-form-field__customerTitle', 'Mr'); | |
await page.type('#customerFirstName', 'Anthony'); | |
await page.type('#customerLastName', 'Smith'); | |
await page.type('input.ss-dynamic-form-field__customerDoBDay', '01'); | |
await page.type('input.ss-dynamic-form-field__customerDoBMonth', '12'); | |
await page.type('input.ss-dynamic-form-field__customerDoBYear', '1980'); | |
await page.type('#customerEmail', '[email protected]'); | |
await page.type('#customerMobile', '01234567'); | |
await page.click('.customer__submit-btn'); | |
//appointment recap page | |
await page.waitFor('#who-change'); | |
// //enable if you wish to amend a booking's date | |
// await page.click('#when-change'); | |
// await page.waitFor(4000); | |
// await page.click('.calendar-ab--slots__slot:nth-child(2)'); | |
// await page.click('.calendar-ab--book') | |
/*enable if you wish to cancel a booking */ | |
//click on cancel booking | |
await page.$eval('.recap__confirm-button', (el) => el.scrollIntoView()); | |
await page.click('.recap__confirm-button'); | |
await page.waitFor('.confirmation--cancel--button'); | |
await page.click('.confirmation--cancel--button'); | |
//cancel recap page loaded | |
await page.waitFor('.card--cancel.card--recap'); | |
//enable this to keep the appointment | |
//await page.click('.recap__appointment-exit-button'); | |
//enable this to amend booking | |
//await page.click('.recap__appointment-change-date-time-button'); | |
//cancel booking | |
await page.click('.recap__appointment-cancelled-button'); | |
/* End of cancel journey */ | |
//await browser.close(); | |
} | |
doSasjourney(); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">//https://codeburst.io/a-guide-to-automating-scraping-the-web-with-javascript-chrome-puppeteer-node-js-b18efb9e9921 | |
const puppeteer = require('puppeteer'); | |
async function doSasjourney() { | |
const browser = await puppeteer.launch({ | |
headless: false, | |
args: ['--start-fullscreen','--window-size=1920,1040'] | |
}); | |
const page = await browser.newPage(); | |
await page.setViewport({ width: 1920, height: 1040 }); | |
await page.goto('http://gb-en.specsavers.local/book/halifax/appointment-type'); | |
//await puppeteer.launch({ devtools: true }); | |
//hide buttons | |
await page.click('#sliding-popup .agree-button') | |
await page.click('.hide-button'); | |
await page.waitFor(2000); | |
//select appointment | |
await page.click('.adult-eye-test--icon .appointment-type--book'); | |
//calendar page loads | |
await page.waitFor('.calendar-ab--slots__slot'); | |
//click on calendar day | |
await page.click('.calendar-ab--slots__slot:last-child'); | |
await page.click('.calendar-ab--book') | |
//customer details page loads | |
await page.waitFor('#customerEmail'); | |
//fill in customer details | |
await page.select('.ss-dyanimic-form-field__customerTitle', 'Mr'); | |
await page.type('#customerFirstName', 'Anthony'); | |
await page.type('#customerLastName', 'Smith'); | |
await page.type('input.ss-dynamic-form-field__customerDoBDay', '01'); | |
await page.type('input.ss-dynamic-form-field__customerDoBMonth', '12'); | |
await page.type('input.ss-dynamic-form-field__customerDoBYear', '1980'); | |
await page.type('#customerEmail', '[email protected]'); | |
await page.type('#customerMobile', '01234567'); | |
await page.click('.customer__submit-btn'); | |
//appointment recap page | |
await page.waitFor('#who-change'); | |
// //enable if you wish to amend a booking's date | |
// await page.click('#when-change'); | |
// await page.waitFor(4000); | |
// await page.click('.calendar-ab--slots__slot:nth-child(2)'); | |
// await page.click('.calendar-ab--book') | |
/*enable if you wish to cancel a booking */ | |
//click on cancel booking | |
await page.$eval('.recap__confirm-button', (el) => el.scrollIntoView()); | |
await page.click('.recap__confirm-button'); | |
await page.waitFor('.confirmation--cancel--button'); | |
await page.click('.confirmation--cancel--button'); | |
//cancel recap page loaded | |
await page.waitFor('.card--cancel.card--recap'); | |
//enable this to keep the appointment | |
//await page.click('.recap__appointment-exit-button'); | |
//enable this to amend booking | |
//await page.click('.recap__appointment-change-date-time-button'); | |
//cancel booking | |
await page.click('.recap__appointment-cancelled-button'); | |
/* End of cancel journey */ | |
//await browser.close(); | |
} | |
doSasjourney();</script></body> | |
</html> |
This file contains hidden or 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
//https://codeburst.io/a-guide-to-automating-scraping-the-web-with-javascript-chrome-puppeteer-node-js-b18efb9e9921 | |
const puppeteer = require('puppeteer'); | |
async function doSasjourney() { | |
const browser = await puppeteer.launch({ | |
headless: false, | |
args: ['--start-fullscreen','--window-size=1920,1040'] | |
}); | |
const page = await browser.newPage(); | |
await page.setViewport({ width: 1920, height: 1040 }); | |
await page.goto('http://gb-en.specsavers.local/book/halifax/appointment-type'); | |
//await puppeteer.launch({ devtools: true }); | |
//hide buttons | |
await page.click('#sliding-popup .agree-button') | |
await page.click('.hide-button'); | |
await page.waitFor(2000); | |
//select appointment | |
await page.click('.adult-eye-test--icon .appointment-type--book'); | |
//calendar page loads | |
await page.waitFor('.calendar-ab--slots__slot'); | |
//click on calendar day | |
await page.click('.calendar-ab--slots__slot:last-child'); | |
await page.click('.calendar-ab--book') | |
//customer details page loads | |
await page.waitFor('#customerEmail'); | |
//fill in customer details | |
await page.select('.ss-dyanimic-form-field__customerTitle', 'Mr'); | |
await page.type('#customerFirstName', 'Anthony'); | |
await page.type('#customerLastName', 'Smith'); | |
await page.type('input.ss-dynamic-form-field__customerDoBDay', '01'); | |
await page.type('input.ss-dynamic-form-field__customerDoBMonth', '12'); | |
await page.type('input.ss-dynamic-form-field__customerDoBYear', '1980'); | |
await page.type('#customerEmail', '[email protected]'); | |
await page.type('#customerMobile', '01234567'); | |
await page.click('.customer__submit-btn'); | |
//appointment recap page | |
await page.waitFor('#who-change'); | |
// //enable if you wish to amend a booking's date | |
// await page.click('#when-change'); | |
// await page.waitFor(4000); | |
// await page.click('.calendar-ab--slots__slot:nth-child(2)'); | |
// await page.click('.calendar-ab--book') | |
/*enable if you wish to cancel a booking */ | |
//click on cancel booking | |
await page.$eval('.recap__confirm-button', (el) => el.scrollIntoView()); | |
await page.click('.recap__confirm-button'); | |
await page.waitFor('.confirmation--cancel--button'); | |
await page.click('.confirmation--cancel--button'); | |
//cancel recap page loaded | |
await page.waitFor('.card--cancel.card--recap'); | |
//enable this to keep the appointment | |
//await page.click('.recap__appointment-exit-button'); | |
//enable this to amend booking | |
//await page.click('.recap__appointment-change-date-time-button'); | |
//cancel booking | |
await page.click('.recap__appointment-cancelled-button'); | |
/* End of cancel journey */ | |
//await browser.close(); | |
} | |
doSasjourney(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment