You want to open a new tab, navigate to a URL, then switch back to the original tab and verify its title. Which code snippet correctly does this in Selenium Java?
hard📝 Application Q15 of 15
Selenium Java - Handling Windows, Frames, and Alerts
You want to open a new tab, navigate to a URL, then switch back to the original tab and verify its title. Which code snippet correctly does this in Selenium Java?
AString original = driver.getWindowHandle();
driver.switchTo().newWindow(WindowType.TAB);
driver.get("https://selenium.dev");
driver.switchTo().window(original);
assert driver.getTitle().contains("Example");
Bdriver.switchTo().newWindow(WindowType.TAB);
driver.get("https://selenium.dev");
String original = driver.getWindowHandle();
driver.switchTo().window(original);
assert driver.getTitle().contains("Example");
CString original = driver.getWindowHandle();
driver.newWindow(WindowType.TAB);
driver.get("https://selenium.dev");
driver.switchTo().window(original);
assert driver.getTitle().contains("Example");