title: Selenium + Python how to listen for change of element
body: <p>The idea is to create a bot to read message from a chat, and all message are in a <code>ul&gt;li</code>(not neccesary to write message), e.g</p>
  
  <pre class="lang-html prettyprint-override"><code>&lt;ul class="message-list"&gt;
    &lt;li class="message"&gt;
     Hello There
    &lt;/li&gt;
    &lt;li class="message"&gt;
     Hello
    &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>I found <code>expected_conditions</code> from Selenium, to handle if element exist/found, but it's always true, because there is a message but I don't want to continue the code if a message was already in chat, that's not the main idea. And after that, I found <code>EventFiringWebDriver, AbstractEventListener</code> and nothing.</p>
  
  <pre class="lang-py prettyprint-override"><code>from selenium import webdriver as wb
  from selenium.webdriver.support.ui import WebDriverWait
  from selenium.webdriver.support.events import EventFiringWebDriver, AbstractEventListener
  from selenium.webdriver.common.keys import Keys
  
  
  class MyListener(AbstractEventListener):
      def before_navigate_to(self, url, driver):
          print("Before navigate to %s" % url)
  
      def after_navigate_to(self, url, driver):
          print("After navigate to %s" % url)
  
  
  driver = wb.Chrome('C:\python\selenium\chromedriver.exe')
  wait = WebDriverWait(driver, 300)
  # ef_driver = EventFiringWebDriver(driver, MyListener())
  driver.implicitly_wait(15)
  driver.get('https://socket.io/demos/chat/')
  driver.switch_to.frame(driver.find_element_by_class_name('iframe-class'))
  InputName = driver.find_element_by_xpath('/html/body/ul/li[2]/div/input')
  InputName.send_keys('MyNameIsJeff')
  InputName.send_keys(Keys.ENTER)
  
  
  </code></pre>