0

I have an iFrame in another iFrame, I´am able to switch to the parent iFrame and then to the child iFrame, but I´am just not able to switch back to the parent one. Is it even possible to switch up top to the parent one, as the driver is in the child iFrame?

2
  • Show your (java?) code in your original post, along with any relevant HTML code. Jul 9 '19 at 15:12
  • Wouldn’t driver.switchTo().defaultContent() help you out? As per Java Docs, it selects either the first frame on the page, or the main document when a page contains iframes.
    – Mh_tm92
    Apr 5 '20 at 10:13
0
  • No. Its not possible to directly access out side.
  • As your driver is currently in child iFrame, Then you can access Parent iFrame.
  • But not directly go for Parent iFrame's top element
0

iFrames are nowadays used in almost all professional software companies and having an experience of 6 years in one of the top IT Security Testing Services companies, I have hardly seen any newly developed application without iFrame. So, to handle these iFrames there are multiple ways as mentioned below -

  1. SwitchTo().frame(int frameNumber) - This works based on the frame index.
  2. SwitchTo().frame(string frameName) - This works based on the name of the frame.
  3. SwitchTo().frame(WebElement frameElement) - This works based on frame webElement

and now if you want to switch back to parent frame, you can use default method as - Switch to Default Content method.

This allows you to navigate back to parent method and can be used as - driver.switchTo().defaultContent();

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.