When I wait for AJAX to finish

This step waits up to 10 seconds for all active XHR and fetch requests to complete, then returns as soon as the network is quiet. It uses the full smart-settle probe: the step resolves when the DOM is ready, no network requests are in flight, no pending setTimeout callbacks remain, and no MutationObserver activity has occurred for at least 250 ms. If the network goes quiet before the 10-second budget is used, the step returns early.

Use this step after triggering a UI action that fires a background request - such as changing a select value that reloads a dependent widget, submitting a form via fetch, or clicking a button that refreshes part of the page. The step is equivalent to "wait until the network is idle" and is kept for phrasing parity with older feature files. Both I and we pronouns are accepted, and the pronoun may be omitted when chaining with And.

Accepted phrasings

When I wait for AJAX to finish
And I wait for AJAX to finish
When we wait for AJAX to finish
And wait for AJAX to finish

Examples

When I wait for AJAX to finish
And I wait for AJAX to finish
When we wait for AJAX to finish
And wait for AJAX to finish

In a real scenario

Scenario: User changes a content format and the editor widget updates
  Given I am logged in as "editor"
  When I go to "/content/add/article"
    And I wait until the page is loaded
    And I should see "Body"

  When I select "full_html" from "body[0][format]"
    And I wait for AJAX to finish
  Then I should see the ".rich-editor" element

  When I select "plain_text" from "body[0][format]"
    And I wait for AJAX to finish
  Then I should see the "#body-plain" element

Related steps

Back to Wait Steps