Take the 2-minute tour ×
Software Quality Assurance & Testing Stack Exchange is a question and answer site for software quality control experts, automation engineers, and software testers. It's 100% free, no registration required.

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,

share|improve this question
    
tried with (String winHandle : driver.getWindowHandles()) { driver.switchTo().window(winHandle); } but its throwing exception "Unable to locate element". –  user2787080 Jun 26 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: http://stackoverflow.com/questions/19112209/how-to-handle-the-new-window-in-selenium-webdriver

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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