使用动作链:
from selenium.webdriver.common.keys import Keysfrom selenium.webdriver.common.action_chains import ActionChainsN = 5 # number of times you want to press TABactions = ActionChains(browser) for _ in range(N): actions = actions.send_keys(Keys.TAB)actions.perform()
或者,由于这是Python,因此您甚至可以执行以下操作:
actions = ActionChains(browser) actions.send_keys(Keys.TAB * N)actions.perform()



