Monday, November 29, 2010

How to handel JavaScript Popups with Ruby/Watir

require 'watir'
require 'watir\contrib\enabled_popup'
include Watir
require 'test/unit'
require 'win32ole'

your codes here till pop-up coming

ie.button(:value, ).click_no_wait

hwnd = ie.enabled_popup(5)
if (hwnd)
w = WinClicker.new
w.makeWindowActive(hwnd)
w.clickWindowsButton_hwnd( hwnd, "OK" )
sleep 5
end

your reaming codes

Wednesday, November 10, 2010

split big number into digit

a=[]
puts "Enter a number"
n=gets
n.to_s.scan(/\d/) {|x| a<< x}
puts a.inspect



Example:

C:\myruby>dd.rb
Enter a number
726594
["7", "2", "6", "5", "9", "4"]

C:\myruby>