Skip to content

docs(java): initialize Page in API testing examples - #42399

Merged
Devin Rousso (dcrousso) merged 1 commit into
microsoft:mainfrom
dcrousso:fix-42368
Aug 26, 2026
Merged

docs(java): initialize Page in API testing examples#42399
Devin Rousso (dcrousso) merged 1 commit into
microsoft:mainfrom
dcrousso:fix-42368

Conversation

@dcrousso

Copy link
Copy Markdown
Contributor

the browser integration examples used Page without initializing it

share one Browser and create an isolated BrowserContext and Page for each test

fixes #42368

@yury-s Yury Semikhatsky (yury-s) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'd not make any of the changes to keep the examples short. We can add // ... where the classes omit some code, but nobody complained so far.

Comment thread docs/src/api-testing-java.md Outdated

private Playwright playwright;
private APIRequestContext request;
private Browser browser;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

These has nothing to do with the api request, I'd not add them here to keep only the code that is relevant to the api request in the example.

Comment thread docs/src/api-testing-java.md Outdated
@BeforeAll
void beforeAll() {
createPlaywright();
createBrowser();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this also doesn't help with understanding the api testing.

@dcrousso

Copy link
Copy Markdown
Contributor Author

but nobody complained so far

this PR is in response to someone filing an issue about how it's confusing so that's not really true anymore

@yury-s

Copy link
Copy Markdown
Member

but nobody complained so far

this PR is in response to someone filing an issue about how it's confusing so that's not really true anymore

They complain that "As a result, readers cannot run these UI-interaction snippets directly after adapting the complete example." and I believe complete example from the docs is in a good shape. The rest are just bits that zoom in to the relevant parts of the snippets. I'd not try to make them perfect. I'm also pretty sure agents won't have any troubles with turning the doc into runnable code. If you still want to add fixtures, they should be local to "Prepare server state via API calls" and "Check the server state after running user actions" sections which actually use page (I don't see any usages of context).

the browser integration examples used `Page` without initializing it

create a local `Browser` and `Page` in each integration example
@dcrousso
Devin Rousso (dcrousso) merged commit 88e2a7a into microsoft:main Aug 26, 2026
3 checks passed
@dcrousso
Devin Rousso (dcrousso) deleted the fix-42368 branch August 26, 2026 18:08
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.

[Docs]: Initialize Page in Java API testing integration examples

2 participants