microsoft / microsoft/playwright-java
[Feature]: OptionsFactory that has access to test instance fields
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 1.6k
- Forks
- 298
- Avg merge
- 3d 2h
- Merged PRs (30d)
- 14
Description
🚀 Feature Request
I'd like the ability to populate Options for use with @UsePlaywright with values that are determined by the running test, not just statically.
The OptionsFactory approach to customizing @UsePlaywright has a big gap - it can't access instance fields of the test. A non-static inner class doesn't work as it requires the outer class as a constructor argument.
Example
@UsePlaywright
@MicronautTest
class MyTest {
@Inject
EmbeddedServer server;
Options getOptions() {
return new Options().setBaseUrl(server.getUrl())
}
@Test
void myTest(Page page) {
}
}
Motivation
I'm trying to use Playwright with a fake server (Spring MockMVC, Micronaut EmbeddedServer, etc). These approaches all inject a server into an instance field of the test class, and one retrieves the base URL from that server. However, OptionsFactory is initialized outside of the test instance scope, and so can't make use of that injected server.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the @UsePlaywright OptionsFactory integration and how it is initialized relative to the test instance. Review the example with an injected EmbeddedServer and determine the lifecycle needed to access instance fields. Done means Options can use values from the running test while existing @UsePlaywright behavior remains supported.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- testing-qa
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100