51Testing软件测试论坛

标题: watir的关于combobox的问题 [打印本页]

作者: huoxingyinzi    时间: 2009-6-14 15:25
标题: watir的关于combobox的问题
我也是名watir初学者,测试的网站是C#编写的
1.关于combox的问题
在编写下拉框时,下拉框的类型是combobox  

网站的源文件是:
<select xtype="combo" ext_errIcoOffset="0" ext_height="18px" ext_selectOnFocus="true" ext_forceSelection="true" ext_mode="local" ext_displayField="Text" ext_valueField="Value" ext_maxHeight="300" ext_listWidth="-1" name="ctl00$ContentPlaceHolderBody$ComboBoxStoreName" onchange="javascript:setTimeout('__doPostBack(\'ctl00$ContentPlaceHolderBody$ComboBoxStoreName\',\'\')', 0)" id="ctl00_ContentPlaceHolderBody_ComboBoxStoreName" style="height:18px;">
<option value="-1">--Please choose--</option>
<option value="120">changsha one</option>
<option selected="selected" value="131">Alberta</option>
</select>

我编写的是:
ie.select_list(:name,'ctl00$ContentPlaceHolderBody$ComboBoxStoreName').set("changsha one")

运行后,总是
underfined method 'set' for #<watir::selectlist:0x2e35164>(Nomethoderror)
后来换成了
ie.select_list(:name, 'ctl00$ContentPlaceHolderBody$ComboBoxStoreName').select_value('changsha one')
运行后,提示找不到select_value这个方法

以为是版本太低了,我装的是watir1.4,不支持这个方法,

2.安装问题
后来按照网上的装了watir-1.6.2.gem,结果连运行都不行,总是提示
C:/Ruby/lib/ruby/gems/1.8/gems/windows-pr-0.9.3/lib/windows/thread.rb:59: uninitialized constant Windows::API::Error (NameError)
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.5.9/lib/win32/process.rb:3
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/ie-process.rb:1
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
        from C:/Ruby/lib/ruby/gems/1.8/gems/watir-1.6.2/lib/watir/ie.rb:45
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `gem_original_require'
        from C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:36:in `require'
        from google.rb:2

网上说是
require 'watir'--->require 'watir/ie'
还是运行报错

麻烦熟悉watir的高手帮帮小妹!在此感激不尽!
作者: godenjoyme    时间: 2009-6-15 22:54
combobox的方法就是select吧,你可以请去查查watir官方的API
作者: huoxingyinzi    时间: 2009-6-20 00:31
哈哈,自己解决了
回答下:
问题1:因为combobox这个地方时分层(div)的,而是作为一个image下拉
ie.image(:id,"ext-gen11").click
ie.div(:text,"changsha one").click
问题2:
出现这个问题是因为windows-pr版本的问题引起了。
0.9.3版本有个小问题
结果的办法是先Gem uninstall
windows-pr
然后再运行 Gem install windows-pr
作者: huoxingyinzi    时间: 2009-6-20 00:32
现在觉得知道watir的方法,编写脚本还很快的
比QTP和Robot还是方便很多!




欢迎光临 51Testing软件测试论坛 (http://bbs.51testing.com/) Powered by Discuz! X3.2