WebDriver open new tab

Viewed 52010

I have trawled the web and the WebDriver API. I don't see a way to open new tabs using WebDriver/Selenium2.0 .

Can someone please confirm if I am right?

Thanks, Chris. P.S: The current alternative I see is to either load different urls in the same window or open new windows.

17 Answers

Thanks for the great idea @Jonathan Azoff !

Here's how I did it in Ruby:

def open_new_window(url)
  a = @driver.execute_script("var d=document,a=d.createElement('a');a.target='_blank';a.href=arguments[0];a.innerHTML='.';d.body.appendChild(a);return a", url)
  a.click
  @driver.switch_to.window(@driver.window_handles.last)
end
Related