How to work with PageObject using Playwright plugin for SpecfFlow?
I am using the Playwright plugin for SpecFlow and I have trouble organizing my code properly. I have followed the sample on the SpecFlow.Actions GitHub repository and created a BasePage and the pages that I want to test that inherit from it. The problem is that each page object creates a new browser instance.
For instance, if I have 3 pages in my web applications HomePage, LoginPage and DetailPage that inherits from my BasePage class:
- DetailPage is the page I want to test
- DetailPage can only be accessed from HomePage
- The user needs to be authenticated to access DetailPage and HomePage
- The user can be authenticated by entering its credentials on LoginPage.
To handle authentication:
- I created a Hook to manage the authentication for all my scenarios wher authentication is needed
- I created methods in LoginPage to fill the credentials fields in the page and get a token
To manage access to my DetailPage:
- I created a Hook that manage the navigation from my Home Page to the DetailPage for all my scenarios testing my DetailPage
- I created methods in HomePage that click on the buttons needed to navigate to the DetailPage
To test my DetailPage I created the methods in DetailPage with the things to test.
This way of doing things seem to follow the example but does not work because each page will create a browser. How should I do that ?
There is an issue about that in the Specflow.Actions github repo
Please sign in to leave a comment.