Created
August 20, 2020 10:22
-
-
Save angelovstanton/5db5f255eb15aa8fa480de530de0c114 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Test | |
public void movingBetweenTabs() { | |
driver.navigate().to("https://www.automatetheplanet.com/"); | |
var firstLink = driver.findElement(By.xpath("//*[@id='menu-item-11362']/a")); | |
var secondLink = driver.findElement(By.xpath("//*[@id='menu-item-6']/a")); | |
String selectLinkOpenninNewTab = Keys.chord(Keys.CONTROL,Keys.RETURN); | |
firstLink.sendKeys(selectLinkOpenninNewTab); | |
secondLink.sendKeys(selectLinkOpenninNewTab); | |
Set<String> windows = driver.getWindowHandles(); | |
String firstTab = (String)windows.toArray()[1]; | |
String lastTab = (String)windows.toArray()[2]; | |
driver.switchTo().window(lastTab); | |
Assert.assertEquals("Resources - Automate The Planet", driver.getTitle()); | |
driver.switchTo().window(firstTab); | |
Assert.assertEquals("Blog - Automate The Planet", driver.getTitle()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment