PowerShell使用internetexplorer.application选择下拉列表项咨询
PowerShell 操作IE COM对象选择JS页面下拉选项问题
实现目标
- 通过PowerShell完成JavaScript实现的页面上下拉列表项选择操作
- 当前进展:已完成站点登录功能,可通过获取DOM元素得到对应元素的一系列关联方法
已编写代码
# Create an ie com object $ie = New-Object -com internetexplorer.application; $ie.visible = $true; $ie.navigate($url); # Wait for the page to load while ($ie.Busy -eq $true){ Start-Sleep -Milliseconds 1000; } # Login Write-Host -ForegroundColor Green "Attempting to login."; # Add login details try { $ie.Document.IHTMLDocument3_getElementsByName("user") = $username $ie.Document.IHTMLDocument3_getElementsByName("pass") = $password $ie.Document.IHTMLDocument3_getElementsByName("submit") Do{Start-Sleep -Milliseconds 100}While($ie.Busy -eq $True) } catch { $_.Exception.Message } #get dropdown elementarray $ie.Document.IHTMLDocument3_getElementById('contentPlaceHolderId') #get methods $ie.Document.IHTMLDocument3_getElementById('contentPlaceHolderId') | gm
当前问题
目前可通过IHTMLDocument3_getElementById方法获取到id为contentPlaceHolderId的下拉元素容器,也可通过管道调用gm命令查看该元素的所有可用方法,但因方法数量过多无法在帖中全部展示,请问如何选中该占位容器内的指定下拉选项?在此先行感谢各位的解答。
内容的提问来源于stack exchange,提问作者Nico
相关产品推荐
相关产品推荐

