PhantomJS - click element
<p>i want to click element on the website and then take a screenshot, how to do it in PahantomJS?</p>

<p>Here is my html:</p>

<pre><code>&lt;html&gt;
&lt;head&gt;
    &lt;title&gt;list&lt;/title&gt;
&lt;/head&gt;
&lt;body class="directory"&gt;
    &lt;input id="search" type="text" placeholder="Search" autocomplete="off"&gt;
    &lt;div id="wrapper"&gt;
      &lt;h1&gt; / &lt;/h1&gt;
      &lt;ul id="files" class="view-tiles"&gt;
        &lt;li&gt;&lt;a href="/build" class="" title="build"&gt;&lt;span class="name"&gt;build&lt;/span&gt;&lt;span class="size"&gt;0&lt;/span&gt;&lt;span class="date"&gt;Wed Oct 12 2016 &lt;/span&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
    &lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>and that what i tried </p>

<pre><code>var page = require('webpage').create();

page.onError = function(msg, trace) {
  return;
};

page.open("http://localhost:9001/", function(status){
    if (status !== 'success') {
        console.log('Unable to load the url!');
        // phantom.exit();
    } else {

        console.log("click");
        page.render('1.png');

            document.getElementById("build").click();

        page.render('2.png');


    page.onConsoleMessage = function(msg, lineNum, sourceId) {
        console.log('CONSOLE: ' + msg + ' (from line #' + lineNum + ' in "' + sourceId + '")');

        if (msg === "finished") {

            console.log("click");


            }
        };
    // phantom.exit();
    }


    // phantom.exit();
});
</code></pre>

<p>How to click it and then take a screenshot to be sure that I move to next page.</p>