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

260
Visualizações
Webdriver IO - firefox browser doesn't recognize browser.acceptAlert() and shows error that it is not a function

I automate scenario where I need to verify that after click on button browser alert is visible for user and contains correct text. Usually I'm working with google chrome and my solutions is working for chrome, bet when I wanted to test scenario on firefox, console throw error TypeError: browser.isAlertOpen is not a function , after some googling I found that isAlertOpen is working only on Chrome browser, but I can't found nothing for firefox. Is there any solution how to do it that it will work for both browsers? My code right now

Steps.js

Then(/^I verify that alert is visible with text $/, async () => {
  await browser.waitUntil(() => browser.isAlertOpen());
  const msg = await browser.getAlertText();
  expect(msg).toEqual('Text on alert');
});
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Yeah, that's true. Because the isAlertOpen method is non-official and undocumented Chromium command. Moreover, there's no similar method for Firefox. However, you can create a function to check the alert is present or not.

function isAlertPresent() {
  return async function() {
    try {
      await this.getAlertText();

      return true;
    } catch (error) {
      if (error.name === 'no such alert') {
        return false;
      } else {
        throw error;
      }
    }
  };
}

This is a simple function that returns another function that tries to get alert text and if it succeeds then it'll return true if an alert is not present it'll return false.

Then you can add it to your step or test:

Then(/^I verify that alert is visible with text $/, async () => {
  //                      ↓ call function
  await browser.waitUntil(isAlertPresent());
  const msg = await browser.getAlertText();
  expect(msg).toEqual('Text on alert');
});

Also, you can consider adding the isAlertPresent function as a custom command. Read more here.

about 4 years ago · Juan Pablo Isaza 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