Selenium WebDriver get Current frame before switch
<p>I have a custom action to find elements, by switching in the certain iFrame.
It uses the following native action:
<code>driver.switchTo().frame(requested_frame)</code>
Currently I am switching back to the default content every-time before switch to the exact iframe.</p>

<p>Now I need to improve it's performance by following scnario:</p>

<ul>
<li>Check the current content/frame</li>
<li>if <code>requested_frame=currentFrame</code> then No need to switch</li>
<li>if <code>requested_frame=null</code> then switch to default (if <code>currentFrame=default</code> then again no need to switch)</li>
<li>if <code>requested_frame!=null &amp;&amp; requested_frame!=currentFrame</code> then switch to default, and switch to <code>requested_frame</code> frame.</li>
</ul>

<p>So all I need now is to get the Current Frame. Is there any way I can get it? </p>