detect new element in html using selenium, python



  • 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()
    


  • 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



Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2