It is an interpolation issue. I figured it out :-

require 'selenium-webdriver'

driver = Selenium::WebDriver.for :firefox
driver.navigate.to "http://en.wikipedia.org/wiki/Cascading_Style_Sheets"

link_arr = driver.find_elements(:xpath,"//a")[0..2]
link_arr.map!{|e| e.attribute("href")}

link_arr.each do |link|
     driver.execute_script("window.open(\"#{link}\")") if link
end

-- 
Posted via http://www.ruby-forum.com/.