<?xml version="1.0" encoding="utf-8"?>
<feed xml:lang="en" xmlns="http://www.w3.org/2005/Atom"><title>Recent changes to 243: Support listeners and/or interceptors for `DomElement` `click` and `type`</title><link href="https://sourceforge.net/p/htmlunit/feature-requests/243/" rel="alternate"/><link href="https://sourceforge.net/p/htmlunit/feature-requests/243/feed.atom" rel="self"/><id>https://sourceforge.net/p/htmlunit/feature-requests/243/</id><updated>2017-01-11T22:28:47.001000Z</updated><subtitle>Recent changes to 243: Support listeners and/or interceptors for `DomElement` `click` and `type`</subtitle><entry><title>Support listeners and/or interceptors for `DomElement` `click` and `type`</title><link href="https://sourceforge.net/p/htmlunit/feature-requests/243/" rel="alternate"/><published>2017-01-11T22:28:47.001000Z</published><updated>2017-01-11T22:28:47.001000Z</updated><author><name>Mark Fulton</name><uri>https://sourceforge.net/u/mfulton26/</uri></author><id>https://sourceforge.net5e7ab194ed89814be06a4763d6834fd21de71b37</id><summary type="html">&lt;div class="markdown_content"&gt;&lt;p&gt;I would like to be able to listen/intercept calls on &lt;code&gt;DomElement&lt;/code&gt; instances to &lt;code&gt;click&lt;/code&gt; and &lt;code&gt;type&lt;/code&gt; so that I can log actions, forward them to another process, modify/reject them, etc. Could this be added?&lt;/p&gt;
&lt;p&gt;Specifically, my use case is as follows:&lt;/p&gt;
&lt;p&gt;HtmlUnit has one of the best HTML/SVG Java document trees that I can find. e.g. It is fairly up-to-date (unlike &lt;code&gt;org.w3c.dom.html&lt;/code&gt; which doesn't have &lt;code&gt;HTMLOutputElement&lt;/code&gt;, etc.). I need to run some automation in real web browsers but Selenium doesn't provide access to the entire DOM so I can't walk the tree and discover what elements are there and interact with them (I have some very dynamic pages that present form fields in different order on different pages with different options depending on previous input like state, zip code, household members, etc.).&lt;/p&gt;
&lt;p&gt;As such, I've written some code to load the page via Selenium &lt;code&gt;WebDriver&lt;/code&gt; and then execute some JavaScript in the remote browser to serialize the remote DOM document and return it along with a list of the associated elements back to the client; now the client has a the serialized XML along with a list of associated &lt;code&gt;WebElement&lt;/code&gt; instances so that once I find an element in the DOM to interact with I can lookup the respective &lt;code&gt;WebElement&lt;/code&gt; instance to control the actual web browser again.&lt;/p&gt;
&lt;p&gt;The client parses the xhtml/svg, walks the tree (e.g. using a &lt;code&gt;TreeWalker&lt;/code&gt;) and discovers elements to interact with, looks up the associated &lt;code&gt;WebElement&lt;/code&gt; and sends the action. This process is then repeated until some objective is achieved (e.g. fill in each form on each presented page until a page with a certain title/heading is encountered).&lt;/p&gt;
&lt;p&gt;This all runs fairly quick (the interaction with the real browser being the slowest part while the "dumping" of the DOM document, parsing, etc. being fairly fast). What I'd like to do however is not have to lookup a Selenium &lt;code&gt;WebElement&lt;/code&gt; from a &lt;code&gt;DomElement&lt;/code&gt; but use &lt;code&gt;DomElement.click&lt;/code&gt; and &lt;code&gt;DomElement.type&lt;/code&gt; directly and set-up a listener/interceptor to make the &lt;code&gt;WebElement&lt;/code&gt; calls.&lt;/p&gt;
&lt;p&gt;In short, I want to use &lt;code&gt;HtmlTextInput&lt;/code&gt;, &lt;code&gt;HtmlPasswordInput&lt;/code&gt;, &lt;code&gt;HtmlSelect&lt;/code&gt;, &lt;code&gt;SvgElement&lt;/code&gt;, etc, etc. as my overall API so that I get full access to the DOM and I get to use a real browser with its JavaScript/CSS processing, etc. but in order to do so I need to be able to hook into the click/type events.&lt;/p&gt;&lt;/div&gt;</summary></entry></feed>