开发者

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

开发者 https://www.devze.com 2023-01-12 19:48 出处:网络
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.

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

精彩评论

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