package com.sv.selenium;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
public class SwitchTabs {
public static void main(String[] args) throws InterruptedException {
WebDriver driver=new ChromeDriver();
driver.manage().window().maximize();
driver.get("file:///C:/Users/user/Desktop/html/parent.html");
driver.findElement(By.linkText("goto page2")).click();
Thread.sleep(3000);
String text1=driver.getWindowHandle();
System.out.println(text1);
Set<String> Allids = driver.getWindowHandle();// iam getting error in this line
System.out.println(Allids);
for(String s:Allids)
{
driver.switchTo().window(s);
}
Thread.sleep(3000);
driver.findElement(By.linkText("goto page3")).click();
Thread.sleep(3000);
driver.quit();
}
}