Close popup() windows

Hi,

Can you please suggest me,how to close/cancel popups/alert/confirm windows?

Thanks in advance.

Hi @rameshsrmm,

which driver do you use?
Have you tried the available acceptPopup method? --> https://codecept.io/helpers/WebDriver/#acceptpopup

cheers,
Chris

I am using WebDriverIO

method:
I.acceptPopup();
or
I.cancelPopup();

yeah, are these methods not working?

yes…not working.

any specific libraries required?

i don’t think so, it depends on how the popup/window is implemented on the webpage you’re trying to test…
Can you share the webpage or at least how the alert/window is implemented on the page?

The popups maybe not JS native. Then you should run JS to interact with them
Something like

I.executeScript(() => {
    document
      .body
      .querySelectorAll<HTMLButtonElement>('#button')
      .forEach(el => el.click());
  });