JellyHead
JellyHead

Reputation: 191

Selenium problem accessing elements within frames

I'm having problems verifying elements in a page made up of framesets and frames.

I'm using the code:

    selenium.selectFrame("relative=up");
    selenium.selectFrame("topFrame");

But it fails with the error "Element topFrame not found". I get similar errors when trying to navigate to any frames.

I've also tried specifying the DOM path, and using indexes, but nothing seems to work.

The HTML looks like this:

<frameset framespacing="0" border="0" frameborder="NO" rows="80,*">
    <frame scrolling="NO" frameborder="NO" src="header.html" noresize="" name="topFrame">
    <frameset framespacing="0" border="0" frameborder="NO" cols="210,*">
        <frame scrolling="NO" frameborder="NO" src="menu.html" name="leftFrame">
        <frame scrolling="YES" bordercolor="#78B0D5" frameborder="YES" src="content.html"     name="mainFrame">
        </frame>
    </frameset>
</frameset>

Any suggestions?

Upvotes: 4

Views: 8915

Answers (3)

rs79
rs79

Reputation: 2321

In my experience, selenium is 'temperamental' when it comes to setting frame contexts. I find it useful to define explicit frame identifiers rather than just rely on context. So in your case, I would use:

selenium.selectFrame("relative=top");
selenium.selectFrame("css=frame[class=...]");

Upvotes: 1

Parth
Parth

Reputation: 11

in the above mentioned command instead of writing name="topFrame" try using id="topFrame". selenium uses the id to identify the object.

Upvotes: 1

Ross Patterson
Ross Patterson

Reputation: 9570

When using relative frame navigation, it obviously all depends upon where you start from. To be absolutely sure of that, we always start our frame navigation with selenium.selectFrame("relative=top");, which positions you at the outer <FRAMESET> level, where selenium.selectFrame("topFrame"); would make sense.

Upvotes: 0

Related Questions