Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

256
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!