开发者

Firewatir: Problems changing selection in select list

I'm new to FireWatir and having some issues changing a selection in a select list. Here's what the HTML looks like:

<div id="softwarelist">  
<select name="TDSOFTWARE" style='width:191;'>  
<option value="QFX">Quicken 2004 or newer-Windows  
<option value="QIF">Quicken 2003 or older-Windows   
<option value="OFX">Microsoft Money 98 or newer  
<option value="QIF">Microsoft Money 97 or older  
<option value="CSV">Microsoft Excel           
</select>  
</div>  

I need to change the selection to CSV.

Here's the line in my script where I am stuck:

browser.div(:id, "softwarelist")

I've sort of randomly tried various methods, but (obviously) none have worked. Using the method 'show_all_objects', like so:

puts browser.div(:id, "softwarelist").show_all_objects

开发者_StackOverflow中文版I get a list of all the various formats... that leads me to believe I am in the right ballpark at least, but really I have no idea as I am new to working with FireWatir.

Can anyone point me in the right direction?


Something like this should work (not tested):

browser.select_list(:name, "TDSOFTWARE").set("Microsoft Excel")

For more information take a look at Selection Boxes page at Watir Wiki.


Your problem is that you are trying to treat the div, which contains the selection list, as if it was the selection list. So you are trying to manipulate the wrong object. you are 'close' because that's the outer container around the list, so show_all_objects will report on the list, which is inside that div.

the code in Zeljko's answer ought to work for you.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜