Powershell..select drop down menu from web page

前端 未结 2 1196
别那么骄傲
别那么骄傲 2021-01-14 14:56

im trying to select a drop down menu on a website but im completely lost on how to do so. i googled the hell out of it but no luck on finding anything. this is what im tryin

相关标签:
2条回答
  • 2021-01-14 15:15

    Found a better solution which will select the value with exact text

    Define a function

    applicationList is the id of the select tag

    test abc is the exact text to match


    function Subscription()
    {
    $x = $IE.document.getElementById("applicationList");
    for($i=0;$i -lt $x.length;$i++)
    {
    If($x.options[$i].text -eq "test abc")
    {
    return $i;
    }}}
    

    Call the Function

    $index=Subscription;
    $IE.Document.getElementById("applicationList").SelectedIndex=$index;
    
    0 讨论(0)
  • 2021-01-14 15:17

    Try this:

    # will select item with label 9
    $dropdown = $ie.Document.getElementById("skuAndSize")
    ($dropdown | where {$_.innerHTML -eq "9"}).Selected = $true
    
    0 讨论(0)
提交回复
热议问题