Saltar al contenido principal

waitForStable

Espera a que un elemento esté estable (sin animación) durante la cantidad de milisegundos proporcionada. Devuelve true si el selector coincide con al menos un elemento que está estable en el DOM, de lo contrario lanza un error. Si la bandera reverse es true, el comando devolverá true si el selector no coincide con ningún elemento estable.

Nota: es mejor desactivar las animaciones en lugar de usar este comando

Uso
$(selector).waitForStable({ timeout, reverse, timeoutMsg, interval })
Parámetros
NombreTipoDetalles
options
opcional
WaitForOptionsopciones de waitForStable (opcional)
options.timeout
opcional
Numbertiempo en ms (valor predeterminado basado en la configuración waitforTimeout)
options.reverse
opcional
Booleansi es true espera lo contrario (predeterminado: false)
options.timeoutMsg
opcional
Stringsi existe, reemplaza el mensaje de error predeterminado
options.interval
opcional
Numberintervalo entre comprobaciones (predeterminado: waitforInterval)
Ejemplos
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();
});
Devuelve
  • <Boolean> return: true si el elemento está estable

Welcome! How can I help?

WebdriverIO AI Copilot