How do I switch between iFrames?

How do I switch between iFrames?

Selenium helps to reach out elements inside frames by focus with in frame. So to navigate between two frames.,

  1. switch to first frame using any one of this . driver.switchTo().frame( frameNumber) switchTo().frame( frameName) switchTo().frame( WebElement)

perform required action with in that frame. Now navigate back to original parent window using

switchTo()defaultContent() or switchTo().parentFrame()

Now from parent window you can switch to another frame. If its nested frame , you no need to navigate back to default window, from parent window ,you can switch to another frame.