I am doing some end-to-end test with CodeceptJS and WebdriverIO helper and I would like to wait an error message in my Vue.js SPA.
I want to know if there is a way to wait for a text asynchronously during the runtime of the test. I don't want to use a wait()
because this would increase the duration of my test, instead I would like that, during the runtime of the test it fails the test if it sees some "Error" text for example.
Like the dontSee()
function but in the background of my test, I can't explain it very well.
Asked
Active
Viewed 1,121 times
1

andzep
- 1,877
- 24
- 35

SciallaMan
- 21
- 5
-
Could you perhaps post some code illustrating what you have tried so far? It sounds to me as though this is a situation where you want to use a Promise. – Marcus Jul 25 '18 at 13:09
2 Answers
1
For example the validate error doesn't appear immediatly, so I need to wait if I see that label in the page. I don't want to stop my tests for ten second, I just would like something like a "Watcher" for that label for some seconds.
I.click('#btnSave');
//I.wait(10);
I.dontSee('Error validate');
I.waitForText('Save successful', 5);
The waitForText()
is perfect for the opposite need. There isn't a function like waitForTextToFail()
.

SciallaMan
- 21
- 5
1
I am not sure I understand your question fully, but I think you might be looking for something like this: http://webdriver.io/api/utility/waitForVisible.html
You will notice that it has a parameter called reverse
which will let you assert for the opposite.
It might look something like this: browser.waitForVisible('#elem', 3000, true);
The reverse
flag also works for the waitForText
method.

Kevin Lalka
- 51
- 7
-
I didn't know this `reverse` parameter, it would be perfect for my intent. Unfortunately codecept's parameters are different and there isn't this functionality. – SciallaMan Jul 27 '18 at 07:55
-
If that is the case, look here: https://codecept.io/acceptance/#waiting It looks like you have access to something called `I.dontSeeElement()` – Kevin Lalka Jul 27 '18 at 14:22