Saturday, 23 May 2015

Switch to default content in Selenium

When we have multiple frames in the web page, we need to switch to the frames to perform operations in specific frame.

There are 2 possibilities.

  1. Page contains frame set
  2. Page contains iframe

In first case, DefaultContent() will hand over the control to the first frame in the frame set. In second case, DefaultContent() will hand over the control to the main document in the page.

Example code in C# is given below.

 //switch to first frame in the frameset.
 driver.SwitchTo().DefaultContent();
//if there are inline frames in the page, switch to the main document of the page.

In JAVA API, we can use similar statement as shown below.
driver.switchTo().defaultContent();


What do you think on above selenium topic. Please provide your inputs and comments. You can write to me at reply2sagar@gmail.com

No comments:

Post a Comment

Buy Best Selenium Books

Contributors