Frame Handling in WebDriver

0
16

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
(Visited 16 times, 1 visits today)

LEAVE A REPLY

Please enter your comment!
Please enter your name here