我在python上使用selenium并想在chrome中打开一个新标签页。 我试过硒动作链没有影响
ActionChains(driver).key_down(Keys.CONTROL).send_keys('t').key_up(Keys.CONTROL).perform()
但这没有效果。什么都没发生。 我也试过
send_keys(Keys.CONTROL+'t')
但这也没有效果。 如何在硒中打开新选项卡?
我在python上使用selenium并想在chrome中打开一个新标签页。 我试过硒动作链没有影响
ActionChains(driver).key_down(Keys.CONTROL).send_keys('t').key_up(Keys.CONTROL).perform()
但这没有效果。什么都没发生。 我也试过
send_keys(Keys.CONTROL+'t')
但这也没有效果。 如何在硒中打开新选项卡?
它可以打开新的标签的方式如下:在Ubuntu 12.04
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
browser = webdriver.Chrome()
browser.get('https://www.google.com')
q = browser.find_element_by_name('q')
q.send_keys(Keys.CONTROL, 't')
browser.close()
铬44.0.2403.89(64位),硒2.46.1。
请注意,我在send_keys()
函数中使用,
而不是+
。
ActionChains(driver).key_down(Keys.CONTROL).send_keys(str('\u0074')).perform()
\ u0074表示字符 'T'
为了按其它字符表示的Unicode字符表 - http://unicode.org/charts/PDF/U0000.pdf
simular问题http://stackoverflow.com/questions/17325629/how-to - 打开一个新窗口 - 浏览器 - 使用硒 - python – dmr
你想打开空的新窗口? –