Handling Frames in Selenium:

Selenium has multiple methods to handle Frames.
  1. driver.switchTo().frame(name) 
  2. driver.switchTo().frame(id) 
  3. driver.switchTo().frame(index) 
  4. driver.switchTo().frame(iframe_element) 
Example:
<iframe name=”content” id=”contentSection”></iframe>
Multiple options:

driver.switchTo.frame(“content”);
driver.switchTo.frame(“contentSection”);
driver.switchTo.frame(0);
driver.switchTo.frame(driver.findElement(By.cssSelector("iframe[id='contentSection']")
)


To get out of Frame:
driver.SwitchTo().DefaultContent()
Switch to Parent Frame:
driver.switchTo().parentFrame();



No comments:

Post a Comment