首页 > 解决方案 > 发送键和弦以打开新标签 Selenium Python

问题描述

我有这个超级简单的代码,我试图在 ChromeDriver 上运行,但它不起作用。Java 等效项工作正常。我想打开一个新标签,但任何发送多个密钥的工作方式都会很棒。

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

提前致谢

标签: pythonseleniumautomationselenium-chromedriver

解决方案


我也无法让你的方法起作用,我不知道为什么。不过,这确实对我有用:

driver.execute_script("window.open('');")

推荐阅读