Dear all,
I am having trouble with the redirection page during a browser test. Despite the sleep(10) and all the page.waitForNavigation() when I finally ask for page.title() the output is not the final page’s title.
Tis is the code:
import { chromium, Frame } from 'k6/experimental/browser';
import { check, sleep } from 'k6';
export const options = {
maxRedirects: 20,
scenarios: {
browser: {
executor: 'shared-iterations',
exec: 'browser',
vus: 1,
maxDuration: '1m',
},
},
};
export async function browser() {
const browser = chromium.launch({ headless: false ,timeout: '120s',slowMo:'500ms'});
const context = browser.newContext();
let page = context.newPage();
await page.goto('http://localhost:5000/', { waitUntil: 'networkidle' });
const cookieButton = await page.locator('//*[@id="cookies-banner"]/div/div[2]/button');
await cookieButton.click();
await page.locator('#company-input').type('Test1');
const continueButton = await page.locator('#company-login-continue-button');
await Promise.all([
page.waitForNavigation(),
continueButton.click(),
]);
/* check(page, {
'Button': (page) => page.locator('//*[@id="login-method-selection-password-login-button"]/p').textContent() == 'USERNAME & PASSWORD',
}); */
sleep(1);
const loginButton = await page.locator('//*[@id="login-method-selection-password-login-button"]/p');
await Promise.all([
page.waitForNavigation(),
loginButton.click(),
]);
sleep(1);
await page.locator('#user-name-input').type('TestUsername');
await page.locator('#password-input').type('TestPassword');
const continueButton2 = await page.locator('//*[@id="password-login-continue-button"]/p');
await Promise.all([
page.waitForNavigation(),
continueButton2.click(),
]);
sleep(10)
console.log(page.title())
await page.close();
await browser.close();
}
Thank you!!