vendredi 4 janvier 2019

NightwatchJS : Issue in accessing async request value in page object

Trying to check OTP flow from nightwatch, while doing that to get real otp need to make one async request to server api. It is working as expected, but the value which we are getting is not substituted in page object chain flow. Not sure what is missing here, please help me to understand the issue.

    const common = require('../../lib/commonSpec');
    module.exports = {
        '@tags': ['sendOtp'],
        'sendOtp': async (browser) => {
            await common.login(browser);
            const page = await browser.page.iiflPage();
            await page.waitForElementVisible('@iiflType', 100000)
                .waitForElementVisible('@sendOtpBtn', 100000)
                .click('@sendOtpBtn')
                .waitForElementVisible('@otpText', 100000)
        },
        '@tags': ['verifyOtp'],
        'enterOtp': async (browser) => {
            const otpValue = await common.getOtp();//getOtp methos has a api request and returns the otpText.
            const page = browser.page.iiflPage();
            page.waitForElementVisible('@otpText', 100000);               
            page.setValue('@otpText', otpValue); 
            console.log('Otp Value ' + otpValue);
        }
    };

Please let me know if any other information is required in this regard.

Aucun commentaire:

Enregistrer un commentaire