Trying to do accessibility automation and want to use shift+tab to go back an element. But can't seem to get anything to work. Tried what the doc imply should work based off their "Example, pressing ctrl+c:":
action = ActionChains(driver)
action.key_down(Keys.SHIFT)
action.send_keys(Keys.TAB)
action.key_up(Keys.SHIFT)
action.perform();
Then I guessed at :
action = ActionChains(driver)
action.key_down(Keys.SHIFT).key_down(Keys.TAB)
action.key_up(Keys.SHIFT).key_up(Keys.TAB)
action.perform();
And:
action = ActionChains(driver)
action.key_down(Keys.SHIFT)
action.key_down(Keys.TAB)
action.perform();
action = ActionChains(driver)
action.key_up(Keys.SHIFT)
action.key_up(Keys.TAB)
action.perform();
And:
action = ActionChains(driver)
action.send_keys(Keys.TAB + Keys.SHIFT).perform();
And:
ActionChains(driver).send_keys(Keys.TAB).perform() # Tabs 1 forward
time.sleep(1)
ActionChains(driver).send_keys(Keys.SHIFT, Keys.TAB).perform() # Tabs 1 backwards
time.sleep(1)
ActionChains(driver).send_keys(Keys.SHIFT, Keys.TAB).perform() # Tabs 1 forward
time.sleep(1)
But none of them work. At least at selenium 3.14 & chrome 71.
So how do I hit shift and tab at the same time in Python Webdriver?
UPDATE: The correct answer, answered the summary question of two keys at the same time. But my specific example, I had tried the correct way to send them but it was working intermittently. This is because unbeknownst to me it was treating the shift key as a press down and not release. So the second time I would try it, it was release shift (and thus not tab backwards every other time). So specially for shift and tab you need to do this to press, shift, tab, then release shift.
# At time of writing this didn't work, but now seems to.
action = ActionChains(context.driver)
action.key_down(Keys.SHIFT)
action.send_keys(Keys.TAB)
action.key_up(Keys.SHIFT)
action.perform()
# Chrome was only taking this at time of writing question.
ActionChains(driver).send_keys(Keys.SHIFT, Keys.TAB, Keys.SHIFT).perform()