SpecFlowOSS / SpecFlow.Actions

BSD 3-Clause "New" or "Revised" License
57 stars 53 forks source link

[Playwright] A new instance of the browser is started #55

Open bloodgang94 opened 2 years ago

bloodgang94 commented 2 years ago

When I create a new page object, a new browser instance opens. In your example, I saw only one class. Are there ways to solve the problem?

TechWatching commented 2 years ago

Same question here. When we are testing a scenario on a page which needs another page to be accessed from, using 2 page objects does not work as a browser instance will be created for each page.

An example would be to have an Home Page with a button that allows to navigate to a "Page To test" only reachable from the Home Page.

matthewearley-payroc commented 2 years ago

Same issue, have a BasePage which is used by a LoginPage to login. LoginPage starts up a browser session and works no problem. When a new page is created after logging in another browser window is opened rather than using the LoginPage session. Any ideas how to resolve?

SabotageAndi commented 2 years ago

Yeah, the example is not the best in this case. I will try to find some time to improve it.

egorsh0 commented 2 years ago

@TechWatching @bloodgang94 @matthewearley-payroc How do you work with blocks? I would like to spread the functionality of individual blocks on the page so as not to create huge classes with pages

Myvryn commented 2 years ago

This is something that is causing me an issue too. It is, in fact, blocking me from continuing to evaluate using Specflow.Actions.Playwright as part of the solution for one of my teams. Any update on this?

bradleyeric95 commented 2 years ago

Any update on this please? The same as @Myvryn I am evaluating Playwright and not sure how to get around this issue.

bloodgang94 commented 2 years ago

I temporarily declined up using SpecFlow.Actions. This approach works great for me :

  1. Created a hook BeforeScenario where I initialize the driver and open the page
  2. Registering a dependency var page = await context.NewPageAsync(); _objectContainer.RegisterInstanceAs(page);
  3. Using the Page Object template, I create page classes from the base class public abstract class BasePage { protected IPage Page { get; } public BasePage(IPage page) => Page = page; }

Everything works fine both using a ready-made docker image and via a web socket (Moon)

Semih21 commented 2 years ago

@bloodgang94 Is that possible that you provide us the Hook and Base Page ?

Semih21 commented 2 years ago

Same issue, have a BasePage which is used by a LoginPage to login. LoginPage starts up a browser session and works no problem. When a new page is created after logging in another browser window is opened rather than using the LoginPage session. Any ideas how to resolve?

I have same issue. Have you an oplossing now?

bloodgang94 commented 2 years ago

Same issue, have a BasePage which is used by a LoginPage to login. LoginPage starts up a browser session and works no problem. When a new page is created after logging in another browser window is opened rather than using the LoginPage session. Any ideas how to resolve?

I have same issue. Have you an oplossing now?

PwSpecFlowDemoTest

Created a small example. This approach has a drawback I didn't figure out how to use Multiple contexts

bheemreddy181 commented 2 years ago

@SabotageAndi It would be great if this issue is fixed - Certainly Cannot use this with multiple page options

bheemreddy181 commented 2 years ago

Curious whether this plugin supports multiple pages, just that the current examples illustrates it wrong ?

bheemreddy181 commented 2 years ago

@SabotageAndi Any thoughts on this ?