fix(mcp): await init page before screenshot#41646
Conversation
| const screenshotTargetLabel = params.target ? params.element || 'element' : (params.fullPage ? 'full page' : 'viewport'); | ||
| const target = params.target ? await tab.targetLocator({ element: params.element, target: params.target }) : null; | ||
| if (!target) | ||
| await tab.waitForInitialized(); |
There was a problem hiding this comment.
I think it should be earlier in the pipeline, most likely in the context.ensureTab
There was a problem hiding this comment.
Good call — ensureTab is the right place. That way all tools (snapshot, evaluate, screenshot, etc.) get the guarantee automatically instead of each one having to remember to await init. I will move the waitForInitialized() call into context.ensureTab() and keep the method on Tab for direct use when needed.
Per review feedback, await tab.waitForInitialized() in context.ensureTab() so all tools benefit from waiting for init-page scripts to complete, not just screenshot. Keep waitForInitialized() on Tab for direct use when needed.
|
Moved |
|
@microsoft-github-policy-service agree |
Test results for "MCP"1 failed 7721 passed, 1235 skipped Merge workflow run. |
Summary
browser_take_screenshotwith--init-pageFixes #41650