In this article we will see the methods to work with Window and Frame(IFRAME elements) in selenium web driver. I use c#(VS2010).

-To switch focus to another window by its Name.
 driver.SwitchTo().Window("The name of the window to select");
Note : If we want to switch the focus, then we use this. Mostly used when we need to change one window to another. The name is in string format for the title of the window.

-To switch focus to another frame by Zero based Index
 -To switch focus to another frame by its name or ID
-To switch focus to An OpenQA.Selenium.IWebDriver frame.( an object of IWebDrive)
Note : In hear, element is a IWebElement type object. Actually its a real web element. For the element object finding, I use
private IWebElement element; // declaring element, outside of method

And for switch frame parameter, I use this
element = driver.FindElement(By.XPath("Xpath Location"));
Note: Xpath location is one of the popular way to identify web elements accurately.

-To switch focus to currently focused element OR the body element [if no element focused]

-To Select either the first frame on the page or the main document when a page contains iFrames

-To switch to the currently active modal dialog
driver.SwitchTo().Alert(); be continued... thanks..:)