How to press “ALT+T” in Selenium webdriver with java. I want to switch tabs by pressing it
问题 I have used below code, but it throws an error saying "Cannot focus on element". Please help. String selectAll = Keys.chord(Keys.ALT,"T"); driver.findElement(By.tagName("html")).sendKeys(selectAll); 回答1: The best way to switch tabs would be to use switchTo(), if you know the new window name: driver.switchTo().window(WINDOW_NAME); Otherwise get a list of the open windows and switch using that: List<String> openTabs = driver.getWindowHandles(); for(String tab in openTabs) { driver.switchTo()