1

I've tried several functions but none seems to be working? For example:

element, _ := webdriver.FindElement(selenium.ByCSSSelector, "body")
element.SendKeys(selenium.ControlKey + "t")
Jonathan Hall
  • 75,165
  • 16
  • 143
  • 189
Kur Ich
  • 53
  • 1
  • 5
  • Does this answer your question? [How to open a new tab using Selenium WebDriver](https://stackoverflow.com/questions/17547473/how-to-open-a-new-tab-using-selenium-webdriver) – Eyk Rehbein Mar 01 '21 at 09:19

1 Answers1

2

Selenium is capable of executing javascript within the browser.

To open a new tab get selenium to run the following:

window.open()

I've not used Selenium & Go before - so I can't comment on the syntax. However it's normally along the lines of driver.ExecuteScript("window.open()"). See if your IDE will help you plug the gap.

After you get a new tab, you typically need to use the .switchTo in order to move selenium to another tab.


updated:

Docs suggest....

// ExecuteScript executes a script.
    ExecuteScript(script string, args []interface{}) (interface{}, error)

see here

RichEdwards
  • 3,423
  • 2
  • 6
  • 22