2

The layout of the hmtl page is the following :

<frameset framespacing="0" border="false" frameborder="0" rows="11%,8%,*">
    <frame name="ENTETE" src="fr_entete.htm" scrolling="no" noresize="" marginwidth="0" marginheight="0">Some elements...</frame>
    <frameset framespacing="0" border="false" frameborder="0" cols="35%,7%,*">
        <frame name="SOMMAIRE" src="fr_sommaire.htm" scrolling="no" noresize="" marginwidth="0" marginheight="0">Some elements...</frame>
        <frame name="OUTIL" src="fr_outil.htm" scrolling="no" noresize="" marginwidth="2" marginheight="0">Some elements...</frame>
        <frame name="LIBRE" src="fr_libre.asp" scrolling="no" noresize="" marginwidth="2" marginheight="0">Some elements...</frame>
    </frameset>
    <frame name="TRAVAIL" src="cdc_rechgen.asp" scrolling="yes" noresize="" marginwidth="5" marginheight="0" frameborder="0">Some elements...</frame>
</frameset>

I need to access to the frame "SOMMAIRE". This frame is a child of a frameset which is in turn a child of a frameset. I succeed in navigate to frame "TRAVAIL" and "ENTETE" directly, but I can't succeed in navigate the frame "SOMMAIRE"...

I've tried :

driver.switch_to_default_content()
driver.switch_to.frame("ENTETE")
driver.switch_to.frame("SOMMAIRE")

But I always have the following exception :

selenium.common.exceptions.NoSuchFrameException: Message: no such frame

I've also read those link, but none of them help me to do what I want...

Link1 Link2 Link3

Thanks a lot.

Community
  • 1
  • 1
otarie
  • 21
  • 1
  • 4

3 Answers3

2

SOMMAIRE frame is not located inside ENTETE frame (and, according to the HTML fragment - it is not inside of any frame actually). This means you don't need to switch to ENTETE first. Just switch directly to SOMMAIRE:

driver.switch_to_default_content()  # in case you were inside an iframe before
driver.switch_to.frame("SOMMAIRE")
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195
  • In fact when I go to this html page (made with asp), an input text is (by default) selected in the frame "TRAVAIL". I don't know if it help or not, but I can switch to "ENTETE" frame, but neither to "SOMMAIRE", nor "OUTIL" nor "LIBRE" frames. – otarie May 25 '15 at 15:01
0

Try navigating to SOMMAIRE using XPATH

driver.switchTo().frame(driver.findElement(By.xpath("xpath_of_SOMMARIE")));
Draken
  • 3,134
  • 13
  • 34
  • 54
neha bedi
  • 146
  • 1
  • 3
  • 12
0

User neha bedi seemed to be on the right track but the response needed editing: Try

driver.switch_to.frame(driver.find_element_by_xpath('xpath_of_SOMMARIE')) 

This worked for me.

Dkellygb
  • 866
  • 2
  • 8
  • 24