Sorry if this is too easy of a question, but I'm fairl开发者_JAVA百科y new to Windows Powershell and all of the tutorials I've looked at for dropdown lists show you how to display one to the user.
Anyway what I am trying to do is test my web application using Powershell. I need to change a dropdownlist to a specific choice, I can use the value or index to do this it doesn't matter to me.
Thanks for any help you can give.
Turns out the easiest way to do it was to just set the value of the control to the index I wanted like this:
$ie = new-object -com "InternetExplorer.Application"
$ie.navigate("mywebsite")
$ie.visible = $true
$doc = $ie.document
$listbox = $doc.getElementByID(listboxID)
$listbox.value = 1
This selects the first value in the list box. I have no idea how to tell what that value is if you don't already know it. Or select based off of text but I don't need that.
How about using WatiN from PowerShell?
精彩评论