Styrow.dev
Question 19 of 64

How to locate a frame in webdriver? OR How to switch from one Frame to another?

Question

How to locate a frame in webdriver? OR How to switch from one Frame to another?

Answer

Select iframe by id

driver.switchTo().frame(ā€œID of the frameā€);

Locating iframe using tagName

driver.switchTo().frame(driver.findElements(By.tagName(ā€œiframeā€).get(0));

Locating iframe using index

//frame(index)

driver.switchTo().frame(0);

frame(Name of Frame)

driver.switchTo().frame(ā€œname of the frameā€);