Best practices

  • Use implicit waits to handle scenarios where elements take time to load, but avoid using them as a default method due to potential increased test execution time.

  • Employ explicit waits to target specific elements or conditions, enhancing test reliability by ensuring elements are interactable before proceeding.

  • Utilize JavaScript execution within explicit waits to check for the 'complete' readyState of the document, ensuring the page has fully loaded before actions are performed.

  • Always define a reasonable timeout for explicit waits to prevent indefinitely hanging tests if the expected condition is never met.

Scrollable code block. Use arrow keys to scroll.

Common issues

  • Ensure that the element locators used in explicit waits are updated and accurate to avoid NoSuchElementException.

  • Adjust the timeout settings based on network speed and page complexity to optimize waiting times without causing unnecessary delays.

  • Consider using WebDriverWait in combination with expected_conditions like visibility_of_element_located to handle AJAX-loaded elements more effectively.

  • Regularly review and update your waiting strategies to adapt to changes in web application behavior and structure, ensuring robustness in automated tests.

Scrollable code block. Use arrow keys to scroll.

Try Oxylabs' Proxies & Scraper API

Residential Proxies

Self-Service

Human-like scraping without IP blocking

From

8

Datacenter Proxies

Self-Service

Fast and reliable proxies for cost-efficient scraping

From

1.2

Web scraper API

Self-Service

Public data delivery from a majority of websites

From

49

Useful resources

Web Scraping with Selenium: Step-by-Step Tutorial
Gabija Fatenaite avatar

Gabija Fatenaite

2026-02-09

Puppeteer vs Selenium: Which to Choose
author avatar

Yelyzaveta Hayrapetyan

2025-05-27

Scrapy vs. Selenium: Which One is Better?
Scrapy vs. Selenium: Which One is Better?
vytenis kaubre avatar

Vytenis Kaubrė

2023-07-12

Get the latest news from data gathering world