Selenium NoSuchFrameException will discuss about one of the frequent exceptions which we will face in selenium webdriver. You might face this kind of exception while automating the application if you have iFrames in your application.


In modern applications people are using iFrames very frequently as if you want to show the information from other sources then will use the frames in the application.


We will face this kind of exception in different kind of scenarios. Will discuss the reasons for this issue and we will know we can overcome this issue.



Below are the causes to face this exception:

Let’s assume in your application if you have a frame and it contains some elements (for example we will take a textbox in this scenarios) and you want to enter something into that textbox.


For this we have captured the locator of the textbox and used the same in the code and everything is correct as per the logic. But after execution of the script we will find NoSuchFrameException.


And best part here is selenium will tell us with the proper exception, instead if it says NoSuchElementException then it will be very difficult us to resolve these kind of scenarios.Actually the issue is, if you have frames in your application then you need to switch to that frame first and then only you will be able to interact with the elements which are there inside the frame in selenium.


Let’s assume one more scenario where you have a webpage with more than one frame. We will call them frame A and frame B. We will assume that we first switched to frame B to check/verify something in the frame B.


If we then try to find frame A, we will get NoSuchFrameException. This is because frame A does not exist in the context of frame B.


To overcome this issue is to always go back to the parent frame before trying to switch to another frame


If you have a frame inside a frame then you no need to go back to parent content. You can directly switch to that frame. But after completion of all the things which you want to perform inside the frames need to come out of the frames to continue further script capturing and execution.


You can use frame IDs or WebElements to locate the frames and then you can switch to them. You can also use frame indexes to switch to them but use this as a last option.

Leave a Reply

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