• 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 more window will open(Child of 1st child window).
  • I have to close both the child windows and have to get back to the Parent window.

    I'm not able to switch the control from child to parent window. I have tried out the below code

     String winHandleBefore = _driver.getWindowHandle();
    for(String winHandle : _driver.getWindowHandles()){
        _driver.switchTo().window(winHandle);
    }
    
    String winHandleAfter = _driver.getWindowHandle();
    

    /performing actions in the child window/

    driver.close();
    _driver.switchTo().window(winHandleBefore);
    
Edit
Report