user2789928
user2789928

Reputation: 23

"This browser does not support frames."

I am using Python + Selenium to interact with a webpage with frameset and frames.

However, I get this error when I do something like print driver.page_source:

<frameset cols="*" border="0" framespacing="0" rows="118,*" frameborder="0" onbeforeunload="unload()">
    <frame src="/xxx/frameset/xxx.html" name="ENTETE_WIN" id="ENTETE_WIN" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" />
    <frame src="/xxx/frameset/bodyFrame.html" name="BODY_WIN" id="BODY_WIN" marginwidth="0" marginheight="0" frameborder="0" scrolling="no" />
    <noframes>
        &lt;body bgcolor="#FFFFFF"&gt;
        This browser does not support frames.
        &lt;/body&gt;
  </noframes>
</frameset>

My selenium version is 2.53.2. I tried with Firefox and Chrome with driver 2.21.

Upvotes: 0

Views: 5504

Answers (1)

timbre timbre
timbre timbre

Reputation: 13970

If I understand your question correctly, you are not getting any error. What driver.page_source shows you is an actual HTML of the page. In your case, the page contains 2 frames, as well as additional section called <noframes>, which the end-user would see if their browser did not support frames. So what you see is not an error targeted at you.

I suggest for your automation, ignore the entire <noframes> section all together. Only very very old browsers (e.g. IE 2) do not support frames (see detailed explanation on frames here).

Now if I understand correctly, your trouble is that you cannot select any elements, because your elements are in frames. Well, Selenium provides whole set of functions to deal with frames. See this for Selenium on Python.

So before selecting any other elements, you need to select and switch to corresponding frame. For example:

driver.switch_to_default_content()
driver.switch_to_frame("ENTETE_WIN")

will switch you to the left frame (the first statement makes sure you are on "main" window to begin with). Or

driver.switch_to_default_content()
driver.switch_to_frame("BODY_WIN")

to switch to the right frame.

All other HTML elements are inside those frames, so you can select them using normal xpath, css and other selectors.

Upvotes: 2

Related Questions