How to switch control from child window to parent window in selenium webdriver?

后端 未结 8 1374
一个人的身影
一个人的身影 2020-12-03 17:38
  • From Parent window I\'m passing the control to child window
  • I\'m performing actions in the child window
  • After performing, from a child window one mor
8条回答
  •  借酒劲吻你
    2020-12-03 18:25

    try the below code.. it worked for me...

    public static void main(String[] args) 
    {
        System.setProperty("webdriver.chrome.driver", "./drivers/chromedriver.exe");
        WebDriver driver = new ChromeDriver();
        driver.manage().window().maximize();
        driver.manage().timeouts().implicitlyWait(10, TimeUnit.SECONDS);
        driver.get("https://www.naukri.com/");
    
        //Get the address of main window
        String p = driver.getWindowHandle();
    
        //get address of all windows
        Set allWH = driver.getWindowHandles();
    
        //get address of all windows and store it in ArrayList
        ArrayList allWHCopy = new ArrayList(allWH);
    
        //close the 2nd window
        for(int i=0;i

提交回复
热议问题