Test Scenario/step:
1. Open a browser say Firefox
2. Navigate to Test URL https://link.testproject.io/bsg
3. Click Login link/button at top right corner --> It opens a new tab
4. Switch to new (2nd) tab and do whatever you need
Selenium Java code:
driver.get(" https://link.testproject.io/bsg");
driver.findElement(By.linkText("Login")).click();
//The following snippet of code is for switching to new tab
Set<String> handles = driver.getWindowHandles();
Iterator<String> it = handles.iterator();
while (it.hasNext()){
String child = it.next();
driver.switchTo().window(child);
}
1. Open a browser say Firefox
2. Navigate to Test URL https://link.testproject.io/bsg
3. Click Login link/button at top right corner --> It opens a new tab
4. Switch to new (2nd) tab and do whatever you need
Selenium Java code:
driver.get(" https://link.testproject.io/bsg");
driver.findElement(By.linkText("Login")).click();
//The following snippet of code is for switching to new tab
Set<String> handles = driver.getWindowHandles();
Iterator<String> it = handles.iterator();
while (it.hasNext()){
String child = it.next();
driver.switchTo().window(child);
}
No comments:
Post a Comment