开发者

Select option on dropdown list for web ui testing automation in windows powershell

开发者 https://www.devze.com 2023-02-18 14:51 出处:网络
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.

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?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号