Free Source Code and Tutorials

Custom Search

Frame Handling in WebDriver

In this post we will discuss about how to handle frame in WebDriver .

Frame handling is very important in Web Application Testing.
An inline frame acronym as iframe is used to insert another document with in the current HTML document or simply a web page into a web page by enabling nesting.

In WebDriver we have inbuilt methods and class to handle the frame.

Below are the mentioned method and syntax:

  1. //Select iframe by id
  3. driver.switchTo().frame(“ID of the frame“);
  5. //Locating iframe using tagName
  6. driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));
  8. //Locating iframe using index
  10. //frame(index)
  11. driver.switchTo().frame(0);
  13. //frame(Name of Frame)
  14. driver.switchTo().frame(“name of the frame”);
  16. //frame(WebElement element)
  17. //Select Parent Window
  18. driver.switchTo().defaultContent();
Facebook Comments
(Visited 2 times, 1 visits today)
Share this

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked * © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!

%d bloggers like this: