0

I trying to switch frame "top" to "body". I tried different ways but I couldn't do it. There is too much source but any of them not working. What is the problem with it? HTML structure is in the link. Page is "jsp".

# 1 
driver.switch_to_frame("body")

# 2
wait.until(EC.frame_to_be_available_and_switch_to_it((By.XPATH,"/html/frameset/frame[3]")))

Maybe the problem is visibility?

2 Answers 2

1

Switch to default content from frame "top" and then switch to "body".

driver.switch_to_default_content()

Sign up to request clarification or add additional context in comments.

Comments

0

As mentioned in question, your trying to switch directly from one frame to another frame, which are on same level in DOM like:

<iframe name="top"></iframe>
<iframe name="body"></iframe>

You need to switch to defaultContent before switching to another frame using:

driver.switch_to.default_content()

Then try to switch to frame body

driver.switch_to_frame("body")

We can not directly switch from one frame to another unless targeted frame is located within current frame.

Ex:

<iframe name="top">
    <iframe name="body"></iframe>
</iframe>

Then, we can use:

driver.switch_to_frame("top")
driver.switch_to_frame("body")

1 Comment

That was a perfect explanation. I did not know. Thank you, sir. @Kuldeep Kamune

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.