Selenium test - Firefox alert disappearing immediately

后端 未结 3 779
余生分开走
余生分开走 2021-01-21 05:31

I am writing a Selenium test on Firefox that deals with an alert. The alert appears for a fraction of a second when the test is run, but when done manually the alert persists. C

3条回答
  •  一整个雨季
    2021-01-21 06:23

    The chosen answer worked for me, but it seems that FirefoxDriver(org.openqa.selenium.Capabilities) is deprecated. The working alternative is:

    FirefoxOptions firefoxOptions = new FirefoxOptions();
    firefoxOptions.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR, UnexpectedAlertBehaviour.IGNORE);
    driver = new FirefoxDriver(firefoxOptions);
    

提交回复
热议问题