import { browser } from ‘k6/browser’;
import { check } from ‘k6’;
const users = [
{ email: ‘rohit1@test.com’, password: ‘QWNjb3VudDogMJSkJ=’, workspaceUrl: ‘https://test.Domainname.com/users/sign_in’ },
{ email: ‘sunil.nr+3838@synup.com’, password: ‘Password@123’, workspaceUrl: ‘https://Test2.Domainname.com/users/sign_in’ },
];
export const options = {
browser: {
type: ‘chromium’, // Correct placement of the browser type
},
scenarios: {
ui: {
executor: ‘shared-iterations’,
iterations: 10,
vus: 2,
maxDuration: ‘1m’,
},
},
thresholds: {
checks: [‘rate==1.0’],
},
};
export default async function () {
const page = await browser.newPage();
try {
const userIndex = __VU - 1; // Use __VU instead of VU
const { email: userEmail, password: userPassword, workspaceUrl } = users[userIndex];
await page.goto(workspaceUrl);
function getTimestamp() {
const now = new Date();
return `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}_${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
}
await page.locator("//input[@id='user_email']").type(userEmail);
await page.locator("//input[@id='user_password']").type(userPassword); // Correct ID
const submitButton = page.locator('input[name="commit"]');
await Promise.all([page.waitForNavigation(), submitButton.click()]);
const header = await page.locator("//span[contains(@class,'styles__Greeting')]").textContent();
check(header, {
header: (h) => h.includes(`Hi, ${userEmail.split('@')[0]}!`), // Use backticks for template literals
});
const timestamp = getTimestamp();
await page.screenshot({ path: `screenshots/screenshot${timestamp}.png` });
} finally {
await page.close();
}
}
export function handleSummary(data) {
return {
‘TestSummaryReport.html’: htmlReport(data, { debug: true }),
};
}
for the above I am getting this error
ARN[0000] There were unknown fields in the options exported in the script error=“json: unknown field "browser"”
execution: local
script: Untitled-3.js
output: -
scenarios: (100.00%) 1 scenario, 2 max VUs, 1m30s max duration (incl. graceful stop):
* ui: 10 iterations shared among 2 VUs (maxDuration: 1m0s, gracefulStop: 30s)
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
ERRO[0000] Uncaught (in promise) browser not found in registry. make sure to set browser type option in scenario definition in order to use the browser module executor=shared-iterations scenario=ui
INFO[0000] [k6-reporter v2.3.0] Generating HTML summary report source=console
INFO[0000] {
“root_group”: {
“name”: “”,
“path”: “”,
“id”: “d41d8cd98f00b204e9800998ecf8427e”,
“groups”: ,
“checks”:
},
“options”: {
“noColor”: false,
“summaryTrendStats”: [
“avg”,
“min”,
“med”,
“max”,
“p(90)”,
“p(95)”
],
“summaryTimeUnit”: “”
},
“state”: {
“isStdOutTTY”: true,
“isStdErrTTY”: true,
“testRunDurationMs”: 1.926
},
“metrics”: {
“checks”: {
“values”: {
“rate”: 0,
“passes”: 0,
“fails”: 0
},
“thresholds”: {
“rate==1.0”: {
“ok”: true
}
},
“type”: “rate”,
“contains”: “default”
},
“data_sent”: {
“type”: “counter”,
“contains”: “data”,
“values”: {
“count”: 0,
“rate”: 0
}
},
“data_received”: {
“type”: “counter”,
“contains”: “data”,
“values”: {
“count”: 0,
“rate”: 0
}
},
“iteration_duration”: {
“contains”: “time”,
“values”: {
“med”: 0.022854,
“max”: 0.975834,
“p(90)”: 0.9555084,
“p(95)”: 0.9656712,
“avg”: 0.21180000000000004,
“min”: 0.014959
},
“type”: “trend”
},
“iterations”: {
“type”: “counter”,
“contains”: “default”,
“values”: {
“rate”: 5192.107995846313,
“count”: 10
}
}
}
} source=console
running (0m00.0s), 0/2 VUs, 10 complete and 0 interrupted iterations