diff --git a/lib/helper/WebDriverIO.js b/lib/helper/WebDriverIO.js index d1a54f63a..458380b31 100644 --- a/lib/helper/WebDriverIO.js +++ b/lib/helper/WebDriverIO.js @@ -843,14 +843,28 @@ class WebDriverIO extends Helper { waitForText(text, sec, context) { sec = sec || 1; context = context || 'body'; - return this.browser.waitUntil(function () { - this.getText(context).then(function (source) { - if (Array.isArray(source)) { - return source.filter(part => part.indexOf(text) >= 0).length > 0; + return this.browser + .waitUntil(function () { + return this.getText(context).then(function (source) { + if (Array.isArray(source)) { + return source.filter(part => part.indexOf(text) >= 0).length > 0; + } + return source.indexOf(text) >= 0; + }); + }, sec * 1000) + .catch((e) => { + + if (e.type === 'CommandError') { + + return proceedSee.call(this, 'assert', text, context); + + } else { + + throw e; + } - return source.indexOf(text) >= 0; + }); - }, sec * 1000); } /** diff --git a/test/data/app/controllers.php b/test/data/app/controllers.php index e97ff807d..86e369535 100755 --- a/test/data/app/controllers.php +++ b/test/data/app/controllers.php @@ -237,3 +237,10 @@ function GET() { header('Set-Cookie: a=; Expires=Thu, 01 Jan 1970 00:00:01 GMT'); } } + +class dynamic { + public function GET() + { + include __DIR__.'/view/dynamic.php'; + } +} diff --git a/test/data/app/index.php b/test/data/app/index.php index f8311b23f..2c67f1631 100755 --- a/test/data/app/index.php +++ b/test/data/app/index.php @@ -37,6 +37,7 @@ '/unset-cookie' => 'unsetCookie', '/external_url' => 'external_url', '/iframe' => 'iframe', + '/dynamic' => 'dynamic', ); glue::stick($urls); diff --git a/test/data/app/view/dynamic.php b/test/data/app/view/dynamic.php new file mode 100644 index 000000000..762f88460 --- /dev/null +++ b/test/data/app/view/dynamic.php @@ -0,0 +1,12 @@ + +
+ +