SpecFlow.Actions icon indicating copy to clipboard operation
SpecFlow.Actions copied to clipboard

[Playwright] A new instance of the browser is started

Open bloodgang94 opened this issue 4 years ago • 13 comments

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?

bloodgang94 avatar Nov 09 '21 09:11 bloodgang94

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.

TechWatching avatar Jan 12 '22 13:01 TechWatching

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?

matthewearley-payroc avatar Mar 04 '22 12:03 matthewearley-payroc

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

SabotageAndi avatar Mar 10 '22 10:03 SabotageAndi

@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

egorsh0 avatar Mar 26 '22 17:03 egorsh0

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?

Myvryn avatar May 26 '22 21:05 Myvryn

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

bradleyeric95 avatar Jun 16 '22 12:06 bradleyeric95

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)

bloodgang94 avatar Jun 16 '22 13:06 bloodgang94

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

Semih21 avatar Jun 29 '22 14:06 Semih21

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?

Semih21 avatar Jun 29 '22 15:06 Semih21

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

bloodgang94 avatar Jul 02 '22 21:07 bloodgang94

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

bheemreddy181 avatar Aug 29 '22 15:08 bheemreddy181

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

bheemreddy181 avatar Aug 29 '22 18:08 bheemreddy181

@SabotageAndi Any thoughts on this ?

bheemreddy181 avatar Sep 01 '22 22:09 bheemreddy181