Aller au contenu principal

waitForStable

Attendre qu'un élément soit stable (ne s'anime pas) pendant le nombre de millisecondes fourni. Renvoie vrai si le sélecteur correspond à au moins un élément stable dans le DOM, sinon lance une erreur. Si le drapeau reverse est vrai, la commande renverra plutôt vrai si le sélecteur ne correspond à aucun élément stable.

Remarque : il est préférable de désactiver les animations plutôt que d'utiliser cette commande

Usage
$(selector).waitForStable({ timeout, reverse, timeoutMsg, interval })
Parameters
NameTypeDetails
options
optional
WaitForOptionsoptions waitForStable (optionnel)
options.timeout
optional
Numbertemps en ms (par défaut basé sur la valeur de configuration waitforTimeout)
options.reverse
optional
Booleansi vrai, il attend l'opposé (par défaut : false)
options.timeoutMsg
optional
Strings'il existe, il remplace le message d'erreur par défaut
options.interval
optional
Numberintervalle entre les vérifications (par défaut : waitforInterval)
Examples
index.html
<head>
<style>
div {
width: 200px;
height: 200px;
background-color: red;
}
#has-animation {
animation: 3s 0s alternate slidein;
}
@keyframes slidein {
from {
margin-left: 100%;
width: 300%;
}

to {
margin-left: 0%;
width: 100%;
}
}
</style>
</head>
<body>
<div #has-animation></div>
<div #has-no-animation></div>
</body>

waitForStable.js
it('should detect that element is instable and will wait for the element to become stable', async () => {
const elem = await $('#has-animation')
await elem.waitForStable({ timeout: 3000 });
});
it('should detect that element is stable and will not wait', async () => {
const elem = await $('#has-no-animation')
await elem.waitForStable();
});
Returns
  • <Boolean> return: vrai si l'élément est stable

Welcome! How can I help?

WebdriverIO AI Copilot