An inline frame is used to embed another document within the current HTML document. It means iframe is actually a webpage within the webpage which have its own DOM for every iframe on the page.

How to switch over the elements in iframes using Web Driver commands:
Basically, we can switch over the elements in frames using 3 ways.
  1. By Index
  2. By Name or Id
  3.  By Web Element
Switch to the frame by index:
Index of the iframe starts with '0'. Suppose if there are 100 frames in page
driver.switchTo().frame(25);  //Switch to 26th frame
driver.switchTo().frame(51); //Switch to 52nd  frame
Switch to the frame by Name or ID:
Name and ID are attributes of iframe through which we can switch to it.
driver.switchTo().frame("name of iframe");
driver.switchTo().frame("id of iframe ");
Switch to the frame by Web Element:
driver.switchTo().frame(WebElement);
How to switch back to the Main Frame:
 To move back to the parent frame
driver.switchTo().parentFrame();
            driver.switchTo().defaultContent();