Using POM with Playwright #2737
Replies: 5 comments 1 reply
-
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.
-
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