Using POM with Playwright #2737
Replies: 6 comments 7 replies
-
The processor function you export ( import { LoginPage } from "../../ui-automation/pages/LoginPage";
// note the argument change from {page} to page
export async function loginFlow(page) {
let loginPage = new LoginPage(page)
await loginPage.loadApp();
await loginPage.login();
} Unrelated, but I noticed you seem to be installing the |
Beta Was this translation helpful? Give feedback.
-
@bernardobridge I tried to adjust it and run it again,it still has an issue reading from an env file, it does not reads the username and password from the env file.
for a work around I had to type these username and password hardcoded like this: import { Page } from "@playwright/test";
import { LoginPage } from "../../ui-automation/pages/LoginPage";
export async function loginFlow(page:Page) {
let loginPage = new LoginPage(page)
await loginPage.loadApp();
await loginPage.login('secret_sauce','secret_sauce');
} why is it not reading from the env file? |
Beta Was this translation helpful? Give feedback.
-
@Romarionijim you can use the |
Beta Was this translation helpful? Give feedback.
-
@bernardobridge I still havn't tried this suggestion yet but it is still a workaround and does not solve the actual issue, if I'm running the test in CI I would only reference the env variables that are stored as secrets and that's it, I think it's an overhead specifying paths since it is a place for errors - this should read the dotenv file. |
Beta Was this translation helpful? Give feedback.
-
Converted this to a discussion, as there's currently no evidence of any issue. We can continue discussing here, and feel free to open an actual issue if you encounter it. |
Beta Was this translation helpful? Give feedback.
-
I am encountering the same issue with my code: artilleryLogin.ts: import { Page } from 'playwright';
export async function artilleryLoginScript(page: Page) {
console.log("Starting artilleryLoginScript...");
await page.goto('http://localhost:3000/signin'); // application locally up
console.log("Navigated to signin page");
await page.getByLabel('Email').fill('XXXXXXXX);
await page.getByLabel('Password').fill('XXXXX');
await page.getByRole('button', { name: 'Login' }).click();
console.log("Clicked login button");
await page.getByRole('link', { name: 'Choose Client Inc.' }).getByRole('button').click();
console.log("Clicked client button");
} artillery.yml: (Formatting may be changed while adding comments, but I followed all the correct indentation): config:
target: http://localhost:3000
engines:
playwright: {}
processor: '../artillery/artilleryLogin.ts'
scenarios:
- engine: playwright
function: 'artilleryLoginScript' ERROR:
I also tried using a config.json file to convert TypeScript to JavaScript, but it did not work. Please help. |
Beta Was this translation helpful? Give feedback.
-
Version info:
I expected to see this happen:
load test for this website when navigating to it
Instead, this happened:
I get the following error:
`errors.Cannot read properties of undefined (reading 'goto'): ................... 1
vusers.created: ................................................................ 1
vusers.created_by_name.0: ...................................................... 1
vusers.failed: ................................................................. 1
Warning: multiple batches of metrics for period
All VUs finished. Total time: 1 second
Summary report @ 19:14:23(+0300)
errors.Cannot read properties of undefined (reading 'goto'): ................... 1
vusers.created: ................................................................ 1
vusers.created_by_name.0: ...................................................... 1
vusers.failed: ................................................................. 1`
Files being used:
LoginPage:
loginFlow.ts (proccessor):
yml file test:
P.S - the url is defined, I tested it in a UI scenario and in the CLI and it works as expected, the url is defined in a dotenv file, I also tried providing the BASE_URL in the CLI when running artillery as mentioned above but im getting the error that is mentioned above.
Beta Was this translation helpful? Give feedback.
All reactions