Skip to content

Commit

Permalink
Fixes issue with westpac login treating headless chrome incompatible (#…
Browse files Browse the repository at this point in the history
…43)

* Fixes issue with not using start/end date correctly
  • Loading branch information
geofflamrock authored Nov 7, 2021
1 parent d184b43 commit 379c3ec
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/silent-rats-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ynab-sync-westpac-au": patch
---

Fixes issue with Westpac login treating headless chrome as an incompatible browser
7 changes: 7 additions & 0 deletions packages/westpac-au/src/export/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,13 @@ export async function login(
loginTimeoutInMs: 2000,
}
): Promise<void> {
// Westpac attempts to detect browser compatibility by checking the user agent and redirects to an error page if it's not compatible.
// When running in headless mode the user agent string contains "HeadlessChrome" which Westpac detects as incompatible,
// so we'll replace the user agent string with a compatible one.
await page.setUserAgent(
(await page.browser().userAgent()).replace("HeadlessChrome", "Chrome")
);

await page.goto(
"https://banking.westpac.com.au/wbc/banking/handler?TAM_OP=login&segment=personal&logout=false"
);
Expand Down
4 changes: 2 additions & 2 deletions packages/westpac-au/src/sync/syncTransactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ export const syncTransactions = async (
const outputFilePath = await exportTransactions(
page,
params.westpacAccount.accountName,
params.options.startDate,
params.options.endDate,
startDate,
endDate,
undefined,
{
debug: params.options.debug || false,
Expand Down

0 comments on commit 379c3ec

Please sign in to comment.