Created
February 28, 2021 18:17
-
-
Save ultimate-qa2/cd47ba19533aa67852ae35da3399653f to your computer and use it in GitHub Desktop.
This file contains 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 windowFrames() { | |
driver.navigate().to("https://the-internet.herokuapp.com/windows"); | |
JavascriptExecutor js = (JavascriptExecutor) driver; | |
js.executeScript(("window.open('https://the-internet.herokuapp.com/windows/new')")); | |
String originalWindow = driver.getWindowHandle(); | |
Set handles = driver.getWindowHandles(); | |
handles.remove(originalWindow); | |
String nextWindow = String.valueOf(handles.iterator().next()); | |
driver.switchTo().window(nextWindow); | |
Assert.assertEquals("New Window", driver.getTitle()); | |
driver.close(); | |
driver.switchTo().window(originalWindow); | |
Assert.assertEquals("The Internet", driver.getTitle()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment