is it possible to detect in selenium, that new dynamic element added in html
msg_box = driver.find_element_by_class_name('_3u328')
msg_box.send_keys('---')
button = driver.find_element_by_class_name('_3M-N-')
button.click()
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.