[Webtest] new window

Dierk Koenig webtest@lists.canoo.com
Thu, 13 May 2004 10:05:22 +0200


This is a multi-part message in MIME format.

------=_NextPart_000_001B_01C438D1.CDF062A0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: 7bit

Hi,

I just got a similar bug report and investigated the issue.

The behaviour comes with links that bear the attribute
target="_blank"

After a "click()" on such a link, HttpUnit opens those pages in a new
"WebWindow" and adds this
window to the open windows list. However, the
webconversation.getCurrentPage()
does not return this page, but still the previous one.

I'm not absolutely sure, but it seems this behaviour was introduced
with the JavaScript support for clicklink.
Marc: could you please verify this?

We failed to include a test for target attributes into our suite of
selftests.
Now I created some and will include them in the distribution as soon as the
issue is solved. Here it is: (html files attached)
    <target name="testClickLinkWithTarget">
        <testSpec name="Clicklink with Target">
            &sharedConfiguration;
            <steps>
                <invoke stepid="start"
                    url="linkpage.html"/>
                <clicklink label="Link to some other Window"/>
				<verifytext text="new almost empty page"/>
                <previousresponse/>
                <clicklink label="Link to top Window"/>
				<verifytext text="new almost empty page"/>
                <previousresponse/>
                <clicklink label="Link to new Window"/>
				<verifytext text="new almost empty page"/>
                <previousresponse/>
            </steps>
        </testSpec>
    </target>

This is an HttpUnit test to expose the handling there:
    public void testBlankTarget() throws IOException, SAXException,
MalformedURLException {
        WebConversation wc = new WebConversation();
        WebResponse resp =
wc.getResponse("http://localhost:9090/selftest/linkpage.html");
        WebLink blankLink = resp.getLinkWith("Link to new Window");
        assertEquals("_blank", blankLink.getTarget());
        blankLink.click();
        WebWindow[] windows = wc.getOpenWindows();
        String newPage =
windows[windows.length-1].getCurrentPage().getText();
        assertTrue(newPage, newPage.indexOf("new almost empty page") > -1);
    }

It would be fairly easy to solve the issue in "clicklink" for the special
case
of "_blank". I suspect that "_top" etc. may also cause problems (e.g. with
framesets).
Marc, all: do you have any idea how we can do this cleanly?

cheers
Mittie


> -----Original Message-----
> From: webtest-admin@lists.canoo.com
> [mailto:webtest-admin@lists.canoo.com]On Behalf Of Jeannie Graham
> Sent: Mittwoch, 5. Mai 2004 23:12
> To: 'webtest@lists.canoo.com'
> Subject: [Webtest] new window
>
>
> Hello group,
>
> 	I've noticed past emails where people have had problems with
> accessing new pop-up windows with Canoo Webtest - and responses that Canoo
> can't do it.
>
> Well, I don't know how, but Canoo Webtest actually performs a verify title
> and the setting of selectfields on a new window for me, but when that new
> window refreshes with a new page, Canoo goes back to the main (first)
> window.   Not sure why or how Canoo can see that second window, nor why it
> leaves it when it refreshes it's page.
>
> I am very interested to see if anyone has had similiar experience and if
> anyone has come up with some trick.
>
> Thanks for any ideas,
> Jeannie
> _______________________________________________
> WebTest mailing list
> WebTest@lists.canoo.com
> http://lists.canoo.com/mailman/listinfo/webtest
>

------=_NextPart_000_001B_01C438D1.CDF062A0
Content-Type: text/html;
	name="newPage.html"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="newPage.html"

<html>
<head>
<title>For clicklink tests</title>
</head>
<body>

<h1>new almost empty page</h1>

</body>
</html>

------=_NextPart_000_001B_01C438D1.CDF062A0
Content-Type: text/html;
	name="linkpage.html"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename="linkpage.html"

<html>
<head>
<title>For clicklink tests</title>
</head>
<body>

<h1>Some links to test the &lt;clicklink...&gt; step...</h1>

<a href="newPage.html" target="_blank">Link to new Window</a>
<a href="newPage.html" target="_top">Link to top Window</a>
<a href="newPage.html" target="some">Link to some other Window</a>

</body>
</html>

------=_NextPart_000_001B_01C438D1.CDF062A0--