selenium-webdriver Switching Frames Switch to a frame using C#


1. Switch to a frame by Index.

Here we are switching to index 1. Index refers to the order of frames on the page. This should be used as a last resort, as frame id or names are much more reliable.


2. Switch to a frame by Name


3. Switch to a frame by Title, Id, or others by passing IWebElement

If you want to switch to a frame by id or title you have to pass in a web element as a parameter:


Also note that if your frame takes a few seconds to come up, you may have to use a wait:

new WebDriverWait(driver, TimeSpan.FromSeconds(10))

Get out of a frame: