Joel Pearson wrote in post #1120740:
> "window.open(link)" tells JavaScript to open a window and go to "link",
> which is not a valid JavaScript variable.


but the "link" only the url string. If I try this way,it works.

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..3]
link_arr.map!{|e| e.attribute("href")}

# link_arr.each do |link|
   # p link
   # #driver.execute_script("window.open(link)")
# end
driver.execute_script('window.open("http://www.wikilovesmonuments.in/?pk_campaign=Centralnotice")')

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