How to handle frame in Selenium WebDriver?

An inline frame acronym as iframe is used to insert another document within the current HTML document or simply a web page into a web page by enabling nesting.

  • id
  • Name
  • tagName
  • index

Example:

driver.switchTo().frame("ID of the frame");
driver.switchTo().frame("name of the frame");
driver.switchTo().frame(driver.findElements(By.tagName("iframe").get(0));
driver.switchTo().frame(0);

 Switch to Parent/Main/Default Window

driver.switchTo().defaultContent();