i have this code, that should enter a login page, login, then goto new url, when ready, find div element with class “.queueRightSide” and click it.
But i am stuck at Promise.
const puppeteer = require('puppeteer');
async function main() {
const browser = await puppeteer.launch({
executablePath: '/usr/bin/google-chrome-stable',
headless: 'new',
});
const page = await browser.newPage();
await page.goto('https://app.bizzy.dk/Login', { waitUntil: 'networkidle0' });
console.log('Now on page: ' + page.url());
page.waitForNavigation({ waitUntil: 'networkidle0' }),
console.log('Beginning log in');
await page.type('#Username', '[email protected]');
await page.type('#Password', 'test123');
await Promise.all([
page.click('input.btn-primary'),
page.waitForNavigation(),
]);
console.log('Finished Log in');
await page.goto('https://app.bizzy.dk/Home/Desktop', { waitUntil: 'networkidle0' });
console.log('Now on page: ' + page.url());
await page.waitForSelector('div.queueRightSide', { timeout: 5000 });
console.log('Awaited div.queueRightSide without timing out');
await Promise.all([
page.click('div.queueRightSide'),
// On click, a popup with class "modal-dialog" will appear.
// Await popup, and click on button with class "withripple" if found, otherwise show error message.
page.waitForNavigation({ waitUntil: 'networkidle0' })
]);
console.log('End of actions on page: ' + page.url());
// Logout too, if possible, or clear login cookie with name: .ASPXAUTH
await browser.close();
}
main();
This is my output when running script:
Now on page: https://app.bizzy.dk/Login
Beginning log in
Finished Log in
Now on page: https://app.bizzy.dk/Home/Desktop
Awaited div.queueRightSide without timing out
/home/user/Documents/phone_script/node_modules/puppeteer-core/lib/cjs/puppeteer/util/Deferred.js:27
this.reject(new Errors_js_1.TimeoutError(opts.message));
^
TimeoutError: Navigation timeout of 30000 ms exceeded