_IELinkClickByText in Powershell v2

function ClickLinkByText ([string]$arg1){
$ie.document.Script.execScript("(`$('*:contains(`"" + $arg1 + "`"):last')).click();");
while($ie.Busy) { Start-Sleep -Milliseconds 100 }
}

If you’re using Powershell v2 to automate IE, and the webpage you’re automating has jQuery, try this out.  I’ve been jealous of this function in Autoit, and this is much faster than the “normal” methods to find the link. If you’re on a weak workstation, much more reliable too (the IE DOM randomly fails for me).

Leave a Reply

Your email address will not be published. Required fields are marked *