0

I am doing playwright java script automation using POM cucumber BDD framework. I initiated page object in Hooks file.

If I want to access that page object in another methods in the same file it is not giving me auto suggested locators like (goto, click, fill, getByLabel).

Like below I have pasted my code, when I wanted to use this.page in AfterStep hook it is not giving me auto suggestions for screenshot.

And when I import this file into step file there also not getting auto suggestions for built in locators

const { Before, After, AfterStep, Status, result} = require('@cucumber/cucumber')
const playwright = require('playwright')
const { chromium } = playwright
const {PageObjectFactory} = require('../Pages/PageObjectFactory')
let status = result;
let page ;

Before(async function(){
    const browser = await chromium.launch({headless:false})
    this.browser = browser
    const context = await browser.newContext()
    this.context = context
    page = await context.newPage()
    this.page = page
})

AfterStep(async function ({ result }) {
    if (result.status === Status.FAILED) {
        await this.page.screenshot({ path: Date.now()+'screenshot1.png' });
    }
});

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.