views:

240

answers:

1

Trying IE Automation with Powershell. Task: Select multiple option value fields and click submitbutton.

HTML looks like:

:
:
:
<center><input type="hidden" name="HF_certType" value="x509"><select name="HF_rvk" size="8" multiple>
<option selected value = "Line 1">Line 1 Option</option>
<option value = "Line 2">Line 2 Option</option>
<option value = "Line 3">Line 3 Option</option>
</select></center>

<p><br>
<table BORDER=0 WIDTH="100%" >
<tr>
<td WIDTH="33%"></td>

<td WIDTH="33%"><input type="submit" value="Submit" name="btn_Submit" tabindex="2"></td>

:
:
:

So with:

$ie=New-Object -comobject InternetExplorer.Application  
$ie.visible=$true 
$ie.Navigate("https://test.com/test.exe")
$ie.Document.getElementById("btn_Submit").Click() 

Line 1 is selected because its default.

How can i select All lines?

How can i select Line 2 ?

A: 

Think i Found the answer myself unless somebody has a better way:

($ie.document.getElementsByTagName("option") | where {$_.innerText -like "*Line 3*"}).IHTMLOptionElement_selected = $True
icnivad