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

给你一囗甜甜゛ 提交于 2019-12-12 12:17:00

问题


Sorry if this is too easy of a question, but I'm fairly 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.


回答1:


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.




回答2:


How about using WatiN from PowerShell?



来源:https://stackoverflow.com/questions/5379922/select-option-on-dropdown-list-for-web-ui-testing-automation-in-windows-powershe

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