Execute Javascript Event Directly from PowerShell
<p>I am navigating to a webpage in Internet Explorer.  I would like to automate the clicking of a link on this webpage.  I am currently looping through all HTML elements with a tag of 'a' on the page until I find the one with the title I am looking for - at which point I .click() it:</p>

<pre><code>$links = $ie.document.getElementsByTagName("a")
Foreach($link in $links )
{
    #look for this field by value
    $link.title
    if($link.title -eq "Link I would like to click"){
        Write-Host $link.click()
    }
}
</code></pre>

<p>The link I'm looking for does not have an ID, so document.getElementById() is not an option.  This particular link has an onclick event defined as:</p>

<pre><code>onclick="jsf.util.chain(this,event,'pageLoadStart();','mojarra.jsfcljs(document.getElementById(\'navPanelForm\'),{\'navPanelForm:j_idt689:j_idt689\':\'navPanelForm:j_idt689:j_idt689\'},\'\')');return false"
</code></pre>

<p>Is there any way I can execute this directly without having to loop through ALL the links?</p>