codeceptjs / CodeceptJS

Supercharged End 2 End Testing Framework for NodeJS
http://codecept.io
MIT License
4.11k stars 724 forks source link

waitForText method doesn't handle the error #2344

Open Elverslane opened 4 years ago

Elverslane commented 4 years ago

Im trying to use waitForText method with text and locator arguments without sec because its already declared in codecept.conf

AND it just freezes. No error, exception and etc. But if I clearly write sec all will be fine. its like I.waitForText(text, 6, locator) - work I.waitForText(text, locator) - doesn't work

Details

mirao commented 4 years ago

I.waitForText doesn't support calling with text and locator only, because sec isn't the last parameter: https://codecept.io/helpers/Puppeteer/#waitfortext

If you don't want to specify sec and take it from your config, you can do it this way (I use it with WebDriver, but I guess it will work will Puppeteer too if you change the helper's name):

Test_test.js:

I.waitForText(text, commonStep.getWaitTimeoutInSec(), locator)

Common.js:

module.exports = {
    getWaitTimeoutInSec() {
        return require("codeceptjs").config.get().helpers.WebDriver.waitForTimeout / 1000;
    }
};