0

I want to open a link in a new tab. I am using watir, watir-webdriver and chrome. I need to press ctrl + T. How do I do it ?

This does NOT help - browser.element.send_keys [:control, 'T']

Exception -

C:/blah/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/keyboard.rb:48:i‌​n assert_modifier': "T" is not a modifier key, expected one of [:control, :shift, :a from C:/blah/selenium-webdriver-2.33.0/lib/selenium/webdriver/common/keyboard.rb:25:i‌​n press'....
stack1
  • 1,004
  • 2
  • 13
  • 28
  • possible duplicate of [How to open a new tab using Selenium WebDriver?](http://stackoverflow.com/questions/17547473/how-to-open-a-new-tab-using-selenium-webdriver) – Mike Laren Jul 09 '15 at 00:38
  • What exactly do you mean by "open a link in a new tab"? If you manually press Ctrl+t on the keyboard, it will simply open a blank tab. If that is your goal, you could have just created a new browser window - ie `browser2 = Watir::Browser.new :chrome`. Perhaps your goal is that when you click on a link, you want it to open in a new tab as opposed to the current tab? – Justin Ko Jul 09 '15 at 03:01
  • I could make a new browser, but i prefer to make a tab instead, something like this - browser2 = current_browser.new_tab(tab_name) – stack1 Jul 09 '15 at 23:48

1 Answers1

2

This is kind of a duplicate. The selenium and watir solutions are identical:

How to open a new tab using Selenium WebDriver with Java?

From the 2nd answer: browser.element.send_keys(:control, 't')

Community
  • 1
  • 1
titusfortner
  • 4,099
  • 2
  • 15
  • 29
  • 2
    Also, note, that webdriver won't let you access new tabs, so even if you open it, you won't be able to do anything with it. – titusfortner Jul 08 '15 at 23:21