Method invocation failed because [System.__ComObject] does not co ntain a method named 'Click'
<p>I'm trying to automate logging in and collecting data from specific site. Here is my code</p>

<pre><code>$ie = New-Object -ComObject InternetExplorer.Application;
$ie.Visible = $true;
$ie.Navigate("somesite");
while($ie.busy){Start-Sleep 1;}
while($ie.ReadyState -ne 4){Start-Sleep 1;}
if($ie.Document -ne $null)
{
    $usertextbox = $ie.Document.GetElementById('username');
    $passtextbox = $ie.Document.GetElementById('password');
    $usertextbox.value = "$user";
    $passtextbox.value = "$pass";
    $okbutton = $ie.Document.getElementsByName('submit')[0];
    $okbutton.Click($false);
}
</code></pre>

<p>Unfortunately I get the following error message</p>

<pre><code>Method invocation failed because [System.__ComObject] does not contain a method named 'Click'.
At line:17 char:5
+     $okbutton.Click($false);
+     ~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (Click:String) [], ParentContainsErrorRecordException
    + FullyQualifiedErrorId : MethodNotFound
</code></pre>

<p>You can see HTML code of the element I use below</p>

<pre><code>&lt;input name="submit" accesskey="l" value="Login" tabindex="4" type="submit" /&gt;
</code></pre>

<p>When I use gm on the $okbutton I get this</p>

<pre><code>PS C:\Windows\system32&gt; $okbutton | gm


   TypeName: System.__ComObject#{3050f57d-98b5-11cf-bb82-00aa00bdce0b}

Name                         MemberType Definition                                                     
----                         ---------- ----------                                                     
addBehavior                  Method     int addBehavior (string, Variant)                              
addFilter                    Method     void addFilter (IUnknown)                                      
appendChild                  Method     IHTMLDOMNode appendChild (IHTMLDOMNode)                        
applyElement                 Method     IHTMLElement applyElement (IHTMLElement, string)               
attachEvent                  Method     bool attachEvent (string, IDispatch)                           
blur                         Method     void blur ()                                                   
clearAttributes              Method     void clearAttributes ()                                        
click                        Method     void click ()
</code></pre>

<p>As far as I see this element is definitely and must contain click() method. But for some reason I'm still failing to call it. Can anyone advise me on that matter?</p>