Visar Baci
Visar Baci

Reputation: 43

Using Powershell to check Checkboxes in IE11

So I am using powershell to search a database that is based in HTML. The HTML with the checkbox is:

INPUT name=extend id=perextend onchange=javascript:disabledPagination(); type=checkbox value=on

Now i have search and tried different options, but still no luck:

$chk = $ie.Document.getElementsByTagName("extend") | where-object {$_.type -eq "checkbox"}
$chk.Checked = $True

But it give me an error:

Property 'Checked' cannot be found on this object; make sure it exists and is se ttable. Property 'Checked' cannot be found on this object; make sure it exists and is settable. At D:\Data\Argos excel\Untitled1.ps1:51 char:1

+ $chk.Checked = $True
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound

Any help would be great. And sorry I am new to powershell if its a common mistake

Upvotes: 1

Views: 3330

Answers (1)

Visar Baci
Visar Baci

Reputation: 43

It seems that i was assigning it the wrong element and looking at debugger:

<td width="230"><input type="checkbox" name="extend" value="on" onchange="javascript:disabledPagination();" id="orgextend">

Then using the ID and .Checked = $true has solved my issue:

$chk = $ie.Document.getElementById("orgextend").Checked = $true 

Upvotes: 1

Related Questions