expose
Exposes properties from helper instances as injectable test arguments.
Use it to access the underlying Playwright/Puppeteer page, the wdio browser client,
or any other helper internal directly from a Scenario:
Scenario('listen for requests', async ({ I, page, browser }) => { page.on('request', r => console.log(r.url())) await page.evaluate(() => 1 + 1) I.amOnPage('/')})The injected value is a live proxy: every property access reads the current
helper property, so mid-test reassignments (popups, switchToNextTab,
openNewTab) are reflected automatically. Calls are not wrapped as
CodeceptJS steps — await page.evaluate(...) runs as native Playwright.
Configuration
Section titled “Configuration”inject maps an injection name to a HelperName.propertyName string. A
value with no dot is shorthand for “first configured browser helper that
exposes this property” (allowed properties: page, browser,
browserContext, context).
plugins: { expose: { enabled: true, inject: { page: 'Playwright.page', browser: 'Playwright.browser', browserContext: 'Playwright.browserContext', frame: 'Playwright.context', // current frame set by switchTo wdio: 'WebDriver.browser', } }}Shorthand:
plugins: { expose: { enabled: true, inject: { page: 'page', // resolves to Playwright.page or Puppeteer.page } }}Caveats
Section titled “Caveats”- The injected value is a
Proxy, not the actualPage/Browserinstance, sopage instanceof Pageisfalse. Use duck typing instead. - Cached method references lose the live binding. Call
page.click(...), notconst click = page.click; click(...). - In dry-run mode the underlying helper property is
undefined; accessing any property on the proxy returnsundefinedrather than throwing.
Parameters
Section titled “Parameters”config