Using Powershell to check Checkboxes in IE11

亡梦爱人 提交于 2019-12-24 12:59:20

问题


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


回答1:


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 


来源:https://stackoverflow.com/questions/28694045/using-powershell-to-check-checkboxes-in-ie11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!