Sweet alert malfunctions in combination with Selenium's browser.click()

  • I have a swal:

                title: 'Success',
                text: 'Something',
                type: 'success',
                closeOnConfirm: true
                $("html, body").animate({
                  scrollTop : 0
                }, 1500);

    HTML for button of interest is .

    Now, if I use Selenium's browser.click('.confirm') the swal does close but the follow-up code i.e. hiding the modal and the animation are not triggered. Is there any way around this? Is there maybe another Action I can use that properly triggers the rest?

  • You should wait for the div with classes sweet-alert and visible and then perform any actions on the alert.

    See the answer from Sundling on 17 Dec 2015 at GitHub sweet alert performs a 500ms fadeIn when opening the modal.

    During this-

    time the OK/Cancel buttons will not run the callback function, it will close the modal instead. An unexpected/confusing behavior according to me.

    sweet alert will add the class visible when the animation has finished.

    Using Capybara for testing you could use the following:

    within ".sweet-alert.visible" do ... end

Log in to reply

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2