โ† Back to libraryQuestion 159 of 273
๐ŸงชSeleniumAdvanced

Handling AJAX Calls

๐Ÿ“– Detailed Explanation:

AJAX (Asynchronous JavaScript and XML) allows parts of a page to update without a full page refresh. Selenium might think the page is 'ready' (DOM loaded) even if the AJAX content is still loading from the server. To handle AJAX, you must wait for the specific AJAX element to appear, not just wait for the page to load. Use Explicit Waits with `ExpectedConditions` like `visibilityOfElementLocated()` or `presenceOfAllElementsLocatedBy()`.

๐ŸŒ Real-World Example:

AJAX is like a restaurant that updates the menu without closing. Selenium needs to wait for the new items to appear, not just wait for the restaurant to load.

๐ŸŽฏ Scenario-Based Interview Question:

How do you automate a 'Search' box that shows suggestions as you type (AJAX)?