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.

2
  • Can you also add where iframe tags are closed? Thanks. Commented May 25, 2015 at 13:25
  • I've edited my post to add where iframe tags are closed. Commented May 25, 2015 at 14:43

3 Answers 3

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")
Sign up to request clarification or add additional context in comments.

1 Comment

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.
0

Try navigating to SOMMAIRE using XPATH

driver.switchTo().frame(driver.findElement(By.xpath("xpath_of_SOMMARIE")));

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.