Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

163
Visualizações
Angular2 E2E Protractor. Wait until element has class

I need find a way to wait with my e2e test (angular2 project) until the tested element gets an specific css class.

Is there any possible way without browser.wait() or browser.sleep()?

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

You've even used the word "wait" in the question, but asking to solve it without the built-in waiting functions. I don't see much sense in that.

We've solved something similar before and came up with a custom wait function which can be used as an Expected Condition with browser.wait():

function waitForCssClass(elementFinder, desiredClass) {
    return function () {
        return elementFinder.getAttribute('class').then(function (classValue) {
            return classValue && classValue.indexOf(desiredClass) >= 0;
        });
    };
};

browser.wait(waitForCssClass($("#myid"), "desiredClass"), 5000);
over 4 years ago · Santiago Trujillo Relatório

0

This function waits for a class to disappears from an element, given the element object (ElementFinder) and the CSS class you want to check for.

    static async waitCssClassToDisappear(elem:ElementFinder, cssClass:string, timeout?: number) {
        await browser.wait(()=>{
            return elem.getAttribute('class').then((value) =>{
                return value.indexOf(cssClass) < 0;
            });
        }, timeout ? timeout : Utils.defaultTimeout, 'CSS class did not disappear within specified timeout');
    }

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda