Tuesday, 10 April 2012

How to handle frame pop ups using Selenium Webdriver

Frames are not exactly treated as pop ups or external windows in Selenium Web driver. There will be a frame id for each frame. We have to invoke this particular frame id to handle the actions related to frames when automationg using selenium 2.0

See the example provided below:


where "companyFlyoutIFrame" is the id of the frame. To obtain the id, inspect the frame object using the firebug.

The above line is the script used to switch the control to the frame. once the control is switched, you can do the actions on the frame as normal selenium commands.

Once you are done with the frame, it is also important to switch the control back to the main window. To do this you can use the following script:


willl switch the controll back to the main window by closing the frame.

Hope it is informative....


  1. What if the id to the frames are dynamic how can we handle that ?

    1. hi Mediha,
      sorry for the late reply, did you find the answer to your question?