Send Keys shift+tab on Selenium Web driver

Viewed 4856

I'm trying to get Selenium to perform SHIFT + TAB (goes to top of page) but the code is not working. Am using Python and am quite new to Selenium

Package imported -

import selenium.webdriver as webdriver    
import selenium.webdriver.support.ui as ui
from selenium.webdriver.common.action_chains import ActionChains    
from selenium.webdriver.common.keys import Keys

Code that I've tried:

 ActionChains(driver)
 key_down(Keys.SHIFT+Keys.TAB)
send_keys(Keys.SHIFT,Keys.TAB)

I expect the page to go to the top with SHIFT+TAB

2 Answers

if you want to shift tab use:

driver.switch_to.window(driver.window_handles[1])

[1] means shift to 2º window, Nº0 = is the first

Related