0

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.

Thanks,

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

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

1

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){  
        driver.switchTo().window(handle);  
        if (driver.getTitle().contains(title)) {
          break;  
        }  
     }
}

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, privacy policy and cookie policy

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