ITSourceCode.com

We Exist to Provide 100% 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
  2.  
  3. driver.switchTo().frame(“ID of the frame“);
  4.  
  5. //Locating iframe using tagName
  6. driver.switchTo().frame(driver.findElements(By.tagName(“iframe”).get(0));
  7.  
  8. //Locating iframe using index
  9.  
  10. //frame(index)
  11. driver.switchTo().frame(0);
  12.  
  13. //frame(Name of Frame)
  14. driver.switchTo().frame(“name of the frame”);
  15.  
  16. //frame(WebElement element)
  17. //Select Parent Window
  18. driver.switchTo().defaultContent();
Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

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