-
Notifications
You must be signed in to change notification settings - Fork 209
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
[Feature]: JUnit: Allow the user to control the Browser object's lifecycle #1691
Comments
Not to say that I'm completely against the idea, but it sounds like a workaround for a limitation of a particular cloud service. Do you know why they require resetting the connection for each test rather than reusing the connection and creating |
I'm not sure what their reasoning is. My guess is that it's a carry-over from how they implemented their selenium tests. There is an API to mark tests as passed/failed but there is no way to start a new test without establishing a new session. |
I see, thanks for providing more context. I commented on the PR. My preference would be to allow calling |
@yury-s I'll test out your proposed solution tomorrow and see how it works out. |
@yury-s using
works:@ExtendWith(BrowserStackTestWatcher.class)
@UsePlaywright(SomeOptions.class)
public class MyTests {
} doesn't work:@UsePlaywright(SomeOptions.class)
@ExtendWith(BrowserStackTestWatcher.class)
public class MyTests {
} I think this trade-off is acceptable for now because this is a one off thing for services like BrowserStack. If you agree I can make the changes in my branch. |
I believe we should address this. I hope the traces can be saved when
This is counter intuitive and it'd be nice if we could avoid that. I hope we can save traces on context close and avoid this problem, but if we don't, this ordering constrain should be a minor limitation. |
@yury-s I really like this idea but there is one drawback that I think can be worked around but before I implement I wanted to get your thoughts: In JUnit, we don't know whether a test passed or failed until the The workaround I can think of is to save the trace always, and then delete the trace if the trace setting is
This would allow us to avoid having the user register their own |
Yes, this sounds good to me. In Node.js we also record the trace if it might be needed when the test is done and then delete it if according to the setting and the test's outcome it should not be preserved. I think it'd be nice if we followed the same logic in the Java por. |
🚀 Feature Request
Add an option that will reset the
Browser
object after each test so cloud services that useBrowserType.connect
can work properly. Example: https://www.browserstack.com/docs/automate/playwright/playwright-capabilities#JavaExample
Inside of the existing
TestWatcher
methods, we can check if the user wants to close the browser after each test and do so. Once the next test starts, the Browser will be re-created by the fixture using the existing options. This will allow a new test session to start in BrowserStack.Motivation
Cloud testing services like BrowserStack launch new sessions using
BrowserType.connect
. Each call toconnect
starts a new test session.This doesn't work properly with current JUnit fixtures because the Browser object is re-used per thread and so all tests that run on the same thread use the same test session in BrowserStack. This becomes one giant test according to BrowserStack.
My suggestion would allow the user to decide when to re-use the browser, which works great locally, but not so well when using cloud testing services.
The text was updated successfully, but these errors were encountered: