waitForExist
Warte die angegebene Anzahl von Millisekunden, bis ein Element im DOM vorhanden ist. Gibt true zurück, wenn der Selektor mindestens ein Element findet, das im DOM existiert, ansonsten wird ein Fehler ausgelöst. Wenn das reverse-Flag auf true gesetzt ist, gibt der Befehl stattdessen true zurück, wenn der Selektor keine Elemente findet.
Info
Im Gegensatz zu anderen Elementbefehlen wartet WebdriverIO nicht darauf, dass das Element existiert, um diesen Befehl auszuführen.
Verwendung
$(selector).waitForExist({ timeout, reverse, timeoutMsg, interval })
Parameter
Name | Type | Details |
---|---|---|
options optional | WaitForOptions | waitForEnabled Optionen (optional) |
options.timeout optional | Number | Zeit in ms (Standardwert basierend auf waitforTimeout Konfigurationswert) |
options.reverse optional | Boolean | wenn true, wartet es auf das Gegenteil (Standard: false) |
options.timeoutMsg optional | String | wenn vorhanden, überschreibt es die Standard-Fehlermeldung |
options.interval optional | Number | Intervall zwischen Prüfungen (Standard: waitforInterval ) |
Beispiel
waitForExistSyncExample.js
it('should display a notification message after successful form submit', async () => {
const form = await $('form');
const notification = await $('.notification');
await form.$(".send").click();
await notification.waitForExist({ timeout: 5000 });
expect(await notification.getText()).to.be.equal('Data transmitted successfully!')
});
it('should remove a message after successful form submit', async () => {
const form = await $('form');
const message = await $('.message');
await form.$(".send").click();
await message.waitForExist({ reverse: true });
});
Gibt zurück
- <Boolean>
return
: true wenn Element existiert (oder nicht, wenn Flag gesetzt ist)