Frame Handling in WebDriver

0
117

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:

[java]

//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”);

//frame(WebElement element)
//Select Parent Window
driver.switchTo().defaultContent();

[/java]
Facebook Comments

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.