title: Can my WebDriver script catch a event from the webpage?
body: <p>I would like my WebDriver script to execute some test after the webpage fires specific event. Is this possible? </p>
  
  <p>In the WebDriver script there would be some kind of event listener:</p>
  
  <pre><code>document.addEventListener("hello", function(){
      console.log("doing tests");
  });
  </code></pre>
  
  <p>That would run when the webpage would executes:</p>
  
  <pre><code>var ev = new Event("hello");
  document.dispatchEvent(ev);
  </code></pre>
  
  <p>Is this possible the other way around, so I could fire an event from WebDriver to the webpage?</p>