@צבי-ש
אין בדיקה של רובוט
רק אימות דו שלבי
אני אוחז פה (שאני לא מצליח לבצע פעולות בדיאלוג)
const puppeteer = require('puppeteer');
(async () => {
let browser;
try {
console.log('Launching browser...');
browser = await puppeteer.launch({ headless: false, defaultViewport: null });
const page = await browser.newPage();
console.log('Navigating to login page...');
const url = 'https://biz2.bankhapoalim.co.il/ng-portals/auth/he/biz-login/authenticate';
await page.goto(url, { waitUntil: 'networkidle2', timeout: 60000 });
console.log('Waiting for username field...');
await page.waitForSelector('#user-code', { visible: true });
console.log('Typing username...');
await page.type('#user-code', 'user', { delay: 100 });
console.log('Typing password...');
await page.type('#password', 'pass', { delay: 100 });
console.log('Clicking login button...');
await page.click('.submit-btn.btn1');
console.log('Waiting for navigation after login...');
await page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 60000 });
console.log('Waiting for OTP input field...');
const otpSelector = 'input[formcontrolname="code"]';
await page.waitForSelector(otpSelector, { visible: true });
console.log('Focusing on OTP input field...');
await page.focus(otpSelector);
console.log('Typing OTP code...');
const otpCode = '123456';
for (const char of otpCode) {
await page.type(otpSelector, char, { delay: 100 });
await page.waitForTimeout(100); // Small delay between keystrokes
}
console.log('Clicking submit button for OTP...');
await page.click('.btn3.next');
console.log('Waiting for navigation after OTP...');
await page.waitForNavigation({ waitUntil: 'networkidle2', timeout: 60000 });
console.log('Waiting for account link...');
await page.waitForSelector('#CURRENTAC', { visible: true });
console.log('Clicking on specified link...');
await page.click('#CURRENTAC');
console.log('Done!');
} catch (error) {
console.error('An error occurred:', error);
} finally {
if (browser) {
console.log('Closing browser...');
await browser.close();
}
}
})();