How do I switch to iframe in Selenium?

How do I switch to iframe in Selenium?

An inline frame (iFrame) is an HTML page that is embedded into another HTML document.

The most popular usage of iFrames is to display advertising within a web page. The HTML tag iframe> is used to expressly reference iFrames in a document. To transition back and forth from iframes, Selenium provides the following built-in techniques.

switchTo.frame(int frameNumber) switchTo.frame(string frameName) switchTo.frame(WebElement frameElement) switchTo().defaultContent()