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

junit: allow user to reset Browser after each test #1692

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

uchagani
Copy link
Contributor

Resolves #1691

closeBrowserContext();
if(options.closeBrowserAfterEachTest != null && options.closeBrowserAfterEachTest) {
BrowserExtension.closeBrowser();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The behavior of closing the browser (rather than just the context) after each test is very specific to BrowserStack implementation and they could solve it better by providing an API for explicitly marking test start/end instead of binding it to the lifetime of the browser connection.

I'd rather the clients, that need to close browsers after each test, implemented their own fixture and just called browser.close() after each test from the fixture. We can add onDisconnect handler to all browser instances that are created via Playwright fixture and clean-up thread local cache when the event is fired. It would also cover the case when the user calls browser.close() in the middle of a test too, so it's something that would make sense to do in any case.

Do you think such approach would make more sense or you'd still prefer to have the option?


public enum Trace {
OFF,
ON,
RETAIN_ON_FAILURE;
}

public Options setCloseBrowserAfterEachTest(Boolean closeBrowser) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we proceed with this option, let's have a test for it.

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

Successfully merging this pull request may close these issues.

[Feature]: JUnit: Allow the user to control the Browser object's lifecycle
2 participants