Skip to content

PlaywrightVsSelenium

Feature Selenium Playwright
Lazy locator resolution No Yes
Retries easy hard
Frames Switch to frame and use webdriver obj No Switch needed, use frame obj
---

Lazy locator resolution

#selenium
search_box = WebDriverWait(driver, 10).until(
    EC.presence_of_element_located((By.ID, "search2"))
)
#refresh the browser manually
search_box.send_keys("test12") # we get exception StaleElementReferenceException, because search_box points to an element that no longer exists in the new DOM.


#playwright
editbox = page.locator("#search2")
#refresh the browser manually
editbox.fill("test") #it works. locator() does not store a fixed DOM element. It re-queries the DOM every time you perform an action