Dusk: Testing an ajax request performed by a Modal onScroll event

Submitted by nezarfadle - 4 years ago

This code shows how to trigger a Modal onScroll event to perform and assert against an ajax request

// Make the first request

        ->clickLink('search') // Assuming this will open the Modal
        ->assertSee('Text 1');

// Assert the next comming text is not there
$browser->assertDontSee('Text 2');

// Trigger the Modal scroll event to perform the second ajax request
// Note: The value  ( 10 ) depends on how you handle the onScroll event

$browser->driver->executeScript('var el = $(".modal-content"); el.scrollTop( el.prop("scrollHeight") + 10 );');

// Wait until the Preloader disappear and make the assertion
        ->assertSee('Text 2');