开发者

Watir / Ruby: How to get the text of the selected item in a drop down list?

Using Watir, how can I return the开发者_如何学Python text of the currently selected item in a drop down list? It appears that getSelectedItems is deprecated.


Use selected_options() instead.

selected_options () Description:

Gets all the selected items in the select list as an array. An empty array is returned if the select box has no selected item. Output:

Array containing the selected items of the select list.

Source


The watir documentation also says you can do  

browser.select_list.selected_options.map(&:text)

but this returns the text in an array, I guess it would be useful to do it this way if you have multiple items selected in the list.

['selected text']
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜