How to debug Firefox alert box closing automatically and being unable to detect the alert in Serenity BDD?
Asked Answered
D

1

1

[main] ERROR net.serenitybdd.core.Serenity - No alert is present (WARNING: The server did not provide any stacktrace information)

My question is exactly similar to this one "Firefox alert box not detected with Selenium WebDriver"

But I am not able to find the solution. Even I have tried all kind of waits, changed Firefox versions and tried the solution mentioned in the shared link. But, either I am not able to implement it or its not working.

When doing this task manually pop up comes up when I click on update button and it's working fine.

But, when I do same action using automation pop-up shows and immediately closes automatically within a fraction of seconds and serenity throws error that No Alert not found. Also, alert window that appears during automation is bit different than the one found during manual execution. Please, refer to the link shared above if you want to see the difference in windows.

  public void i_click_update_button() throws InterruptedException {
    btn_update.waitUntilClickable().click(); // clicks the button & pop-up comes
  }      

  public void Accept_POP_UP() throws InterruptedException {

    getAlert().accept(); // code to accept the alret. I have already tried implementing wait & everything. problem is pop-up comes & immediately closes automatically
}
Denysedenzil answered 6/12, 2016 at 6:24 Comment(4)
I find it odd that the alerts are not the same when executed manually vs through script. That makes me think they aren't executing the same steps. Please post the test code where you call these different methods so we can see the flow. A link to the page would be nice also.Segno
@JeffC, Thanks for the response..!! I can assure you that steps are being executed fine. Because, when running via script, the POP-UP flashed for a second & then it just gets dismissed automatically. Not, giving a chance to the selenium to accept the pop-up. Now, the issue is why it just flashes for a sec & then goes away...!! :( Anyway, by which we can accept it automatically or any way to stop it from getting dismissed?? Note: I cannot post the Link of page as its my client site. sorry for that. But, flow is fine I have checked it many times click button then wait & accept popup.Denysedenzil
Could this be the root cause? A bypassed call to fxdriver.modals.clearFlag_ ... cf. #44568902Yttria
I also had this issue and found the solution here: https://mcmap.net/q/473674/-selenium-test-firefox-alert-disappearing-immediatelyIdiolect
A
0

Have you switched the driver on the alert box

driver.switchTo().alert();

Anisole answered 6/12, 2016 at 10:9 Comment(1)
Hi Mayank..Yes I have tried that but not working. Problem is that the POP-UP comes up & then it gets automatically closed by itself. I am not sure why this is happening. If I do it manually it works fine. And, pop-up remains in the browser waiting for response..!!Denysedenzil

© 2022 - 2024 — McMap. All rights reserved.