Handling the Frames in Selenium?

frames tag

In this tutorial, you will learn how to handle the frames in selenium. In general Frames declared with <iframe> </iframe> tag.

iframe means inline frame. iframe is a HTML document embedded inside of another HTML document.

iframes may be located with below details:

  • Frame Number or Index
  • Frame Name or Frame ID
  • Frame WebElement

To switch to Frame or Frames,  we will use SwitchTo().frame() command.

  1. driver.switchTo().frame(2); /* if frame contains index use this*/
  2. driver.switchTo().frame(“testng”); /* if frame contains name use this*/
  3. driver.switchTo().frame(“IF1”); /* if frame contains ID use this*/
  4. WebElement iframeElement = driver.findElement(By.id(“IF1”));
    //now use the switch command
    driver.switchTo().frame(iframeElement);

 

Hi, this is kumar, Founder & Chief Editor of www.alltechmedhas.com, working as Senior Software Engineer in QA Automation Process, Robotic Process Automation Developer. I have total experience of little more than 6 years. I have worked on variety of test automation projects and development projects.

Leave a Reply

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

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