Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

259
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda