is it possible to detect in selenium, that new dynamic element added in html

msg_box = driver.find_element_by_class_name('_3u328')

    button = driver.find_element_by_class_name('_3M-N-')

2 Answers 2


If you know what element will be added you can use explicit wait with :

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec

is_found = WebDriverWait(webdriver, time).until(ec.presence_of_element_located((by, locator)))

Small info on waits can be found here


You can find (in a loop) all elements which match your condition with find_elements_by_* getting the list of elements and check if the list is changed. If yes - that would mean new element was added.

Comparing previous list and new one you will detect which element exactly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.