Rayrun
← Back to Discord Forum

Use POM and Specflow

How have you guys handled to use SpecFlow with Page Object Models?

What I'm most curious about is; How do you share the same IPage? Or do you prefer to create an entire new IPage for each scenarie?

This thread is trying to answer question "How to use SpecFlow with Page Object Models and whether to share the same IPage or create a new one for each scenario?"

1 reply

Create a Base.cs file with that inside:

public class Base { protected IPage Page; public Base(IPage page) => Page = page; }

Inside your other Pages files you will have:

`public class LoginPage : Base { public LoginPage(IPage page) : base(page) { }

public async Task LogIn(string email, string pass)
    {
        await Page.GetByPlaceholder(.......).FillAsync(email);
        await Page.GetByPlaceholder(........).FillAsync(pass);
        await Page.GetByRole(AriaRole.Button, new() { Name = ........}).ClickAsync();
        await Assertions.Expect(Page.GetByText(........)).ToBeVisibleAsync();
    }
}`

Related Discord Threads

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 luc@ray.run.