Rayrun
← Back to Discord Forum

I am getting TypeError: Cannot read properties of undefined (reading 'getByRole')

my solution has page objects defined in a separate file, when i am running test for one particular test i get this error as shown in screenshot I have also attached the snippet where i am using the page object, please help me to figure out where it is wrong

image.png
image.png
Screenshot_2023-06-23_at_20.12.28.png

This thread is trying to answer question "How to fix the TypeError related to 'getByRole' in the user's implementation of Page Object Model?"

2 replies

your pom implementation is wrong, check example in the docs:

https://playwright.dev/docs/pom

constructor does not set values to any class members

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].