-1

using a MAC OS im trying to open a new tab using selenium firefox webdriver

url = "https://google.com" 

mail = wd.Firefox()  

mail.get(url)

 time.sleep(1)

 actions = ActionChains(mail) mail.find_element_by_xpath("/html/body/div[2]/div[2]/div[1]/h2/span[2]/span[1]").click() 

time.sleep(1) 

ActionChains(mail).key_down(Keys.COMMAND).send_keys('t').key_up(Keys.COMMAND).perform()  

mail.close()

 mail.quit()
c0d3x27
  • 193
  • 2
  • 15

1 Answers1

5

if you are using chrome/firefox you can run this javascript.

window.open("https://google.com","_blank")

Python:

driver.execute_script("window.open('https://google.com','_blank')")
supputuri
  • 13,644
  • 2
  • 21
  • 39