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

559
Visualizações
IgnoreExceptionTypes does not work (C# Webdriver)

I have found that in C# whether using the WebDriverWait class or the DefaultWait class, in either case the IgnoreExceptionTypes method appears not to work.

I.e. in either case when running against my page a StaleElementReferenceException is thrown despite the fact I am instructing the code to ignore these exceptions.

WebDriverWait example :

public void WaitElementToBeClickable(IWebElement element)
    {
        var wait = new WebDriverWait(Driver, TimeSpan.FromSeconds(60));
        wait.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(StaleElementReferenceException));
        wait.Until(ExpectedConditions.ElementToBeClickable(element));
    }

DefaultWait example :

public IWebElement SafeWaitForDisplayed(IWebElement webElement) {

    var w = new DefaultWait<IWebElement>(webElement);
            w.Timeout = TimeSpan.FromSeconds(30);
            w.IgnoreExceptionTypes(typeof(NoSuchElementException), typeof(StaleElementReferenceException));
            return w.Until(ctx =>
            {
                var elem = webElement;
                if (elem.Displayed)
                    return elem;
                else
                    return null;
            });
    }

Any suggestions gratefully received. There appears to be very little on the web about usage of this particular method and others have found it not to work also with no workarounds suggested.

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

0

The IgnoreExceptionTypes will only last throughout the wait until it times out. I am using the DefaultWait and like you was expecting it to return null. It does not. When the timeout is reached it will throw the exception. Consequently I have enclosed it in a try catch to handle the exception appropriately on 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