0

I am trying to navigate on a page with nested frames. The page structure looks like this:

<frameset name="framesetContainer">
  <frame name="WebTopMenu">
  ...
  </frame>
  <frame name="WebContent">
    <frameset name="framesetTopContainer">
      <frameset name="framesetWSTopMenu">
        <frame name="frameTitle">
        ...
        </frame>
        <frame name="frameTopMenu">
        ...
        </frame>
      </frameset>
      <frameset name="framesetLeftMenuContentContainer">
        <frameset name="framesetLeftMenuContainer">
        ...
        </frameset>
        <frame name="frameContent">
        ...
        </frame>
      </frameset>
    </frameset>
  </frame>
</frameset>

The links to navigate reside in the frameTopMenu frame and the content is loaded into frameContent.

I am using the WebDriver API of Selenium (2.35.0). The following code runs fine without any exception, it finds the correct link but somehow the click() call does not have any effect and the content is not loaded into the inner frame.

driver.switchTo().frame("WebContent").switchTo().frame("frameTopMenu");
driver.findElement(By.id("link01")).click();

Do I miss something?

The frame structure cannot be changed...unfortunately.

gadget
  • 1,978
  • 18
  • 21
  • 1
    I'm guessing that this is not an IFrame issue. Rather, that the JS that is attached to the click is not being performed. I would recommend selecting an outer/inner element of the element with the id of `link01`, and try clicking that, or to simulate a click via Javascript. – Nathan Merrill Sep 18 '13 at 15:06
  • hmmm interesting! It works by not using the click() method of the WebElement but executing the following js: `((JavascriptExecutor) driver).executeScript("document.getElementById('link01').click();");` Thanks for suggesting! It seems to be a selenium bug then. – gadget Sep 18 '13 at 15:18
  • Is it legal to have a as a _child_ of a ? I didn't think it was. Maybe your browser lets you get away with it, but Selenium is getting confused. – Phil Perry Sep 19 '13 at 18:58

2 Answers2

1

switch to any frame element , just use driver.switchTo().frame("framename");

Once we switched to one frame, if we need to switch to another frame, we have to switch to the parent frame.For that use

driver.switchTo().parentFrame();

If you use driver.switchTo().defaultContent();, it may not work. so go for driver.switchTo().parentFrame();, it works fine.

Juhan
  • 1,283
  • 2
  • 11
  • 30
0

Try below solution for nested frames.Hope it works

driver.switchTo().frame("WebContent").switchTo().
  frame("framesetTopContainer").switchTo().
  frame("framesetWSTopMenu").switchTo().
  frame("frameTitle");
Nico Haase
  • 11,420
  • 35
  • 43
  • 69
sreenath reddy
  • 103
  • 1
  • 2
  • 9