(ZT)Simple Watir/Ajax examples
上一篇 /
下一篇 2009-07-15 23:15:19
/ 个人分类:RUBY
require 'watir'
require 'test/unit'
# Quick example of Ajax examples using Watir, should work with versions
# 1.5.1.1148 and above.
class Ajax_Example <
Test::Unit::TestCase
include Watir
def test_scriptaculous_autocompleter
browser = Browser.start('http://demo.script.aculo.us/ajax/autocompleter')
browser.text_field(:id, 'contact_name').set('al')
# need to fire a key press event after setting the text since the js is handling
# keypress events
browser.text_field(:id, 'contact_name').fire_event('onkeypress')
# the li/lis tags are available in watir 1.5.1
wait_until {browser.div(:id, 'contact_name_auto_complete').lis.length > 0}
puts browser.div(:id, 'contact_name_auto_complete').lis.length
puts browser.div(:id, 'contact_name_auto_complete').li(:index, 5).text
browser.div(:id, 'contact_name_auto_complete').li(:text, 'Alan Jochen').click
end
end
收藏
举报
TAG: