Following are the ways with which you can handle iFrames:
- SwitchTo().frame(int frameNumber): This works based on the frame index.
- SwitchTo().frame(string frameName): This works based on the name of the frame.
- SwitchTo().frame(WebElement frameElement): This works based on frame webElement.
Now if you want to switch back to the parent frame, you can use the default method as - Switch to Default Content method. This allows you to navigate back to parent method and can be used as - driver.switchTo().defaultContent();