Skip to content

Commit

Permalink
fix: leumi new login logic (#818)
Browse files Browse the repository at this point in the history
Co-authored-by: Eran Sakal <[email protected]>
  • Loading branch information
eransakal and Eran Sakal authored Dec 15, 2023
1 parent 61c5350 commit fe263a8
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/scrapers/leumi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,17 @@ import {
fillInput,
clickButton,
waitUntilElementFound,
pageEvalAll,
pageEvalAll, pageEval,
} from '../helpers/elements-interactions';
import { SHEKEL_CURRENCY } from '../constants';
import {
TransactionsAccount, Transaction, TransactionStatuses, TransactionTypes,
} from '../transactions';
import { ScraperScrapingResult } from './interface';
import { waitForNavigation } from '../helpers/navigation';
import { getDebug } from '../helpers/debug';

const debug = getDebug('leumi');
const BASE_URL = 'https://hb2.bankleumi.co.il';
const LOGIN_URL = 'https://www.leumi.co.il/';
const TRANSACTIONS_URL = `${BASE_URL}/eBanking/SO/SPA.aspx#/ts/BusinessAccountTrx?WidgetPar=1`;
Expand Down Expand Up @@ -188,10 +190,18 @@ async function fetchTransactions(page: Page, startDate: Moment): Promise<Transac


async function navigateToLogin(page: Page): Promise<void> {
const loginButtonSelector = '#enter_your_account a';
const loginButtonSelector = '.enter-account a[aria-label*="כניסה לחשבונך"]';
debug('wait for homepage to click on login button');
await waitUntilElementFound(page, loginButtonSelector);
await clickButton(page, loginButtonSelector);
debug('navigate to login page');
const loginUrl = await pageEval(page, loginButtonSelector, null, (element) => {
return (element as any).href;
});
debug(`navigating to page (${loginUrl})`);
page.goto(loginUrl);
debug('waiting for page to be loaded (networkidle2)');
await waitForNavigation(page, { waitUntil: 'networkidle2' });
debug('waiting for components of login to enter credentials');
await Promise.all([
waitUntilElementFound(page, 'input[placeholder="שם משתמש"]', true),
waitUntilElementFound(page, 'input[placeholder="סיסמה"]', true),
Expand Down

0 comments on commit fe263a8

Please sign in to comment.