Fix for multi-level frame issue

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Fix for multi-level frame issue

GW-5
In findElement, it calls findElementBy, passing in the document.  If this doesn't return the element, it iterates through the window's frames and calls findElementBy once per frame.  It will not find an element that is more than 1 frame deep.

The fix:

Pass in the window instead of the document and have findElementBy call itself recursively for each frame until the element is found.

In findElement, pass in window and remove the frames loop:

    var element = this.findElementBy(locatorType, locatorString, this.currentWindow);

in findElementBy:

    this.findElementBy = function(locatorType, locator, inWindow) {
        var locatorFunction = this.locationStrategies[locatorType];
        if (! locatorFunction) {
            throw new SeleniumError("Unrecognised locator type: '" + locatorType + "'");
        }
        var result = locatorFunction.call(this, locator, inWindow.document);
        for (var i = 0; i < inWindow.frames.length && result == null; i++) {
            result = this.findElementBy(locatorType, locator, inWindow.frames[i]);
        }
        return result;
    }
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1161&messageID=3301#3301

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Fix for multi-level frame issue

GW-5
I have an issue that confirm your diagnostic.
My page is composed by multi-level frame :
root
--|--- blank
--|--- page
---------|--- menu
---------|--- body

I used selenium IDE to record my test. I wanted to check text presence in "body" frame.
Selenuim IDE produced :
<tr>
        <td>selectWindow</td>
        <td>body</td>
        <td></td>
</tr>
<tr>
        <td>assertTextPresent</td>
        <td>Bienvenue dans l'application ???</td>
        <td></td>
</tr>
But when I launch the test, I get :
# [info] Executing: |selectWindow | body | |
# [error] Window does not exist

I tried to select "page" frame before, but if the selection of "page" frame works, I can't have access to "body" frame...

I will try your patch as soon as I get the sources.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1161&messageID=3323#3323

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Fix for multi-level frame issue

GW-5
I tried your solution, but it doesn't fix the problem. The function getTargetWindow had to be modified :
// First look in the map of opened windows
    var targetWindow = this.openedWindows[windowName];
    if (!targetWindow) {
        var evalString = "this.getContentWindow().window." + windowName;//Only search for 1 level frames
        targetWindow = eval(evalString);
    }

I think a kind of loop should solve the problem. But as I'm a newbie in Javascript, I need more time to propose a fix.
I will propose a test case to illustrate the problem too.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1161&messageID=3329#3329

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Fix for multi-level frame issue

GW-5
In reply to this post by GW-5
In 0.6.0 I didn't need to change anything except what I listed.  I just did a directory diff to confirm.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1161&messageID=3332#3332

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Fix for multi-level frame issue

GW-5
Can you confirm that this test works for you ?

[b]selenium\tests\TestMultiLevelFrame.html[/b]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <meta content="text/html; charset=ISO-8859-1"
 http-equiv="content-type">
  <title>Test Multi-Level Frame</title>
</head>
<body>
<table cellpadding="1" cellspacing="1" border="1">
  <tbody>
    <tr>
      <td rowspan="1" colspan="3">Test Multi-Level Frame<br>
      </td>
    </tr>

    <tr>
      <td>open</td>
      <td>./tests/html/test_multi_level_frame.html</td>
      <td> </td>
    </tr>

    <!-- Select first level frame -->
    <tr>
      <td>selectWindow</td>
      <td>frame2</td>
      <td> </td>
    </tr>
   <tr>
      <td>selectWindow</td>
      <td>theFrame</td>
      <td> </td>
    </tr>
    <tr>
      <td>assertTextPresent</td>
      <td>Click here for next page via absolute link</td>
      <td> </td>
    </tr>

  </tbody>
</table>
</body>
</html>

[b]selenium\tests\html\test_multi_level_frame.html[/b]
<html>
<frameset cols="20%, 80%">
                <frame src="./test_click_page2.html" id="frame1" name="frame1">
                <frame src="./test_framed_page.html" name="frame2">
</frameset>
</html>
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1161&messageID=3334#3334

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Fix for multi-level frame issue

GW-5
Sorry for the ugly layout of my last post. I didn't manage to have correct carriage return.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1161&messageID=3335#3335

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Fix for multi-level frame issue

GW-5
I have submited a bug report with a patch : http://jira.openqa.org/browse/SEL-191
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1161&messageID=3336#3336

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: Fix for multi-level frame issue

GW-5
I'm confused, but after reflexion and use with Selenium IDE, your patch is needed in addition of mine.
You just have a little mistake :

for (var i = 0; i < inWindow.frames.length && result == null; i++) {
            result = this.findElementBy(locatorType, locator, inWindow.frames[b][i][/b] );
        }

I will update the bug report.
---------------------------------------------------------------------
Posted via Jive Forums
http://forums.openqa.org/thread.jspa?threadID=1161&messageID=3344#3344

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]