I am using xk6-browser to automate a workflow which involve-
Opening Home Page (Page 1)
Enter username , password, click submit button
on clicking submit, it redirects to another page (Page 2)
Perform some action on Page 2 which opens Page 3
My Test Looks like -
export function webtest() {
const browser = chromium.launch({
args: [], // Extra commandline arguments to include when launching browser process
debug: true, // Log all CDP messages to k6 logging subsystem
devtools: true, // Open up developer tools in the browser by default
env: {}, // Environment variables to set before launching browser process
executablePath: null, // Override search for browser executable in favor of specified absolute path
headless: false, // Show browser UI or not
ignoreDefaultArgs: [], // Ignore any of the default arguments included when launching browser process
proxy: {}, // Specify to set browser's proxy config
slowMo: '1000ms', // Slow down input actions and navigations by specified time
timeout: '60s', // Default timeout to use for various actions and navigations
});
const page = browser.newPage();
page.goto(Utils.getBaseUrl()', { waitUntil: 'load' }).
then(() => {
page.$(selectors.username).type('xyz')
page.$(selectors.password).type('abc')
return Promise.all([
page.waitForNavigation(),
page.$(selectors.loginBtn).click()
]).then(() => {
page.screenshot({ path: 'screenshots/01_login.png' }),
page.waitForSelector(selectors.Input),
page.$(selectors.Input).type('xyz')
page.waitForSelector('//div[contains(text(),"xyz")]')
return Promise.all([
page.waitForNavigation(),
page.$("").click()
])
}).then(() => {
page.waitForSelector(selectors.FullName),
check(page, {
'Patient Page': page.locator(selectors.FullName).textContent() == '',
});
page.screenshot({ path: 'screenshots/02_Page.png' })
}).finally(() => {
page.close();
browser.close();
})
})
How I can measure metrics for different pages e.g. Loading of home page, then after login loading of page2, then page3
I am also have the api test in same class, i.e. I am running performance test in hybrid mode (both api and ui), is it possible to get iteration duration for both test api and ui test separately.
The latest (unreleased) version of xk6-browser now supports await and async keywords If youâre comfortable with building from source then you can follow the guide here â NOTE: Instead of running go install go.k6.io/xk6/cmd/xk6@latest you will need to use go install go.k6.io/xk6/cmd/xk6@main to build from the main branch. We hope to release the latest version of xk6-browser in 1 or 2 weeks, so you can wait for that.
In the meantime, while waiting for the latest release, you can still use the second approach that is outlined in How to read output of xk6-browser - #2 by ankur, which uses influxdb and grafana. This will allow you to select and group metrics based on the URL.
Yes, for now you should be able to work with the URLs of pages that were navigated to by your test, and they will be populated in influxdb. Unfortunately the group names arenât being populated in influxdb yet, which we believe is due to the same issue i referenced in my previous post.