We are switching from Selenium RC to Webdriver, but most of the commands after converting in to Webdriver are not working .

The web driver statement for selenium.selectwindow(" title") is driver.switchTo().window(v2); is not working (String v2=driver.getWindowHandle();) and getting exception as

org.openqa.selenium.NoSuchFrameException: Unable to locate frame: {c4fea83b-a784-4278-a490-762bdf80a7df}

Kindly suggest.


  • tried with (String winHandle : driver.getWindowHandles()) { driver.switchTo().window(winHandle); } but its throwing exception "Unable to locate element". Jun 26, 2014 at 7:16

2 Answers 2


The getWindowHandle() function returns the current window, I think you cannot switch to the current window.

You want to use getWindowHandles() to find other windows.

For an example and similar issue see: https://stackoverflow.com/questions/19112209/how-to-handle-the-new-window-in-selenium-webdriver


This is how I implemented a quick utility function to switch to a window based on the title:

public static void switchToWindowWithTitle(String title, WebDriver driver) {
    Set<String> windowHandles = driver.getWindowHandles();
    for(String handle : windowHandles){  
        if (driver.getTitle().contains(title)) {

This iterates over the window handles looking for the right one, and switches to it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.