Skip to content

Commit

Permalink
added hacks to work with AC
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul Bauer committed May 1, 2020
1 parent f616d6e commit 4c08724
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"moment-timezone": "^0.5.26",
"mssql": "^5.1.0",
"parse-duration": "^0.1.1",
"puppeteer": "^1.18.1",
"puppeteer": "^1.20.0",
"shelljs": "^0.8.3",
"prompt-sync": "^4.1.7",
"timetable-fns": "^0.1.16",
Expand Down
2 changes: 2 additions & 0 deletions src/Engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,8 @@ class Engine {
}
if (docker) {
args.push('--no-sandbox', '--headless', '--disable-dev-shm-usage')
} else {
args.push('--no-sandbox')
}

if (remoteAddress === "") {
Expand Down
11 changes: 10 additions & 1 deletion src/Searcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,16 @@ class Searcher {
return page.evaluate((values) => {
for (var key in values) {
if (values.hasOwnProperty(key)) {
const arr = document.getElementsByName(key)

// AC has same name both one-way and round-trip option buttons (tripTypeRoundTrip)
// so for this, use value instead
var arr;
if (key=="tripTypeOneWay") {
arr = [ document.getElementById('tripTypeRoundTrip2') ]
} else {
arr = document.getElementsByName(key)
}

if (arr.length === 0) {
throw new Error(`Missing form element: ${key}`)
}
Expand Down
6 changes: 6 additions & 0 deletions src/engines/ac/searcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ module.exports = class extends Searcher {
}
await this.clickAndWait('button.btn-primary.form-login-submit')

// aeroplans new website is SUPER slow, and navigates multiple times before login dance is done
// so the hacky workaround is to just wait...
await page.waitFor(10000)

// TODO: check if the "verify your email" dialog is appearing for new accounts, since it'll never work in that case...

// Check for errors
const msgError = await this.textContent('div.form-msg-box.has-error span.form-msg')
if (msgError.includes('does not match our records')) {
Expand Down

0 comments on commit 4c08724

Please sign in to comment.