0

I have this super simple code I'm trying to run on ChromeDriver but it's not working. The Java equivalent works fine. I want to open a new tab but any working way to send multiple keys would be great.

driver.get("https://www.google.com")
action = ActionChains(driver)
action.key_down(Keys.CONTROL).send_keys("t").key_up(Keys.CONTROL).perform()

Thanks in advance

Mick
  • 796
  • 4
  • 8
  • you can refer to this question: https://stackoverflow.com/questions/28431765/open-web-in-new-tab-selenium-python – sunilbaba Jan 23 '21 at 03:39
  • @sunilbaba I saw that post before, it didn't work for me. I think something was patched that no longer allows sending multiple keys that way on Chrome. Keys.chord() no longer works for me in Java either – Mick Jan 23 '21 at 03:43

1 Answers1

1

I haven't been able to get your method to work either, I'm not sure why. This did work for me though:

driver.execute_script("window.open('');")
goalie1998
  • 1,427
  • 1
  • 9
  • 16
  • Also, after that, run ```driver.switch_to.window(driver.window_handles[1])``` to interact with the new tab – goalie1998 Jan 23 '21 at 03:46
  • What about sending chords in general? What if I want to press ctrl + 1? – Mick Jan 23 '21 at 04:41
  • 1
    I'm not sure, I think interacting with the pages themselves is fine, but interacting with chrome the browser you should use ```window_handles``` to navigate between them. – goalie1998 Jan 23 '21 at 04:50