In previous versions of SilkTest this was not possible. Even if an item was disabled in a HtmlPopupList it was still valid to pick this item even though it would trigger no event. Using Javascript technology introduced in SilkTest 7.1 it is now possible to look into the control and return the properties for each available choice. Items which are disabled in the HtmlPopupList will have the disabled flag set. e.g. [-] testcase Test1() appstate none [ ] [ ] int i [ ] [ ] // Get the JavaScript source index of the Html Pop up List [ ] [ ] integer iSelectIndex = Val(MyBrowser.MyPopupList.ExecMethod("sourceIndex")) [ ] [ ] // Get Count for number of items in the PopUpList [ ] [ ] int iListCount = MyBrowser.MyPopupList.GetItemCount() [ ] [ ] [-] for i = 1 to iListCount [ ] [ ] // return the name of each element in the list [ ] [ ] string sString = MyBrowser.MyPopupList.ExecMethod("document.all[{iSelectIndex}].children[{i}].text") [ ] [ ] // return if property is true or false [ ] [ ] string sVal = MyBrowser.MyPopupList.ExecMethod("document.all[{iSelectIndex}].children[{i}].disabled") [ ] [ ] print (sString," = ", sVal) Old KB# 21533
↧