Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
bloodgang94 opened this issue Nov 9, 2021 · 13 comments
Open

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

bloodgang94 opened this issue Nov 9, 2021 · 13 comments

Comments

@bloodgang94
Copy link

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
Copy link

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
Copy link

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
Copy link
Contributor

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

@egorsh0
Copy link

egorsh0 commented Mar 26, 2022

@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
Copy link

Myvryn commented May 26, 2022

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
Copy link

bradleyeric95 commented Jun 16, 2022

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

@bloodgang94
Copy link
Author

bloodgang94 commented Jun 16, 2022

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
Copy link

Semih21 commented Jun 29, 2022

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

@Semih21
Copy link

Semih21 commented Jun 29, 2022

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
Copy link
Author

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
Copy link

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

@bheemreddy181
Copy link

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

@bheemreddy181
Copy link

@SabotageAndi Any thoughts on this ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants