Re: Problems with IFrames
"Wolfgang Fahl - BITPlan" <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Organization | bitplan GmbH |
| Message-ID | <[email protected]> |
Al,
I'm ready to check this with you in detail.
You might want to check out the latest svn trunk revision and add the test
case below to com.meterware.httpunit.WebFrameTest. I've tried to resemble
what you sent in your e-mail. If i test it it throws and exception - just
comment out the exception handling to see this.
Yours
Wolfgang
/**
* test I Frame with a Form according to mail to mailinglist of 2008-03-25
* Problems with IFrames by Allwyn D'souza
* @throws Exception
*/
public void testIFrameForm() throws Exception {
String login="//Login.html (main page that is loaded - this page embed the IFrame).\n"+
" \n"+
"<html>\n"+
"<Head>\n"+
"<Script>\n"+
"<!--\n"+
"function SetLoginForm(name, password, Submit) {\n"+
" document.loginForm.name.value = name;\n"+
" document.loginForm.password.value = password;\n"+
" \n"+
" document.loginForm.submit();\n"+
"}\n"+
"-->\n"+
"</Script>\n"+
"</Head>\n"+
"<Body>\n"+
"<Form name=\"loginForm\" action=\"/LoginController\" method=\"Post\">\n"+
"<input type=\"hidden\" name=\"name\" value=\"\" />\n"+
"<input type=\"hidden\" name=\"password\" value=\"\" />\n"+
"</Form>\n"+
"<Center>\n"+
"<IFrame name=\"login\" id=\"login\" src=\"LoginDialog.html\" />\n"+
"</Center>\n"+
"</Body>\n"+
"</html>\n";
String loginDialog="// LoginDialog.html - IFrame\n"+
" \n"+
"<html>\n"+
"<Head>\n"+
"<Script>\n"+
"<!--\n"+
"function SubmitToParent(action) {\n"+
" parent.SetLoginForm(document.submit_to_parent.name.value,document.submit_to_parent.password.value);\n"+
"}\n"+
"-->\n"+
"</Script>\n"+
"</Head>\n"+
"<Body>\n"+
"<Form id=f1 name=\"submit_to_parent\" method=\"Post\">\n"+
"<input type=\"text\" name=\"user\" value=\"\" />\n"+
"<input type=\"text\" name=\"password\" value=\"\" />\n"+
"<input type=\"submit\" name=\"Ok\" value=\"login\" onClick=\"SubmitToParent('Submit')\" />\n"+
"</Form>\n"+
"</Body>\n"+
"</html>\n";
defineWebPage("Login",login);
defineWebPage("LoginDialog",loginDialog);
WebResponse response = _wc.getResponse( getHostPath() + "/Login.html" );
WebResponse bottomFrame = _wc.getFrameContents("login"); // load the <Iframe>
WebForm form = bottomFrame.getFormWithName("submit_to_parent");
form.setParameter("user","aa");
form.setParameter("password","xx");
try {
WebResponse submitResponse = form.submit(); // This response contains the same page, does not log the user in. Load the same
//page
} catch (ScriptException se) {
// TODO clarify what should happen here ...
// throw se;
}
}
From: Allwyn D'souza <[email protected]>
To: Discussion of use and development of HttpUnit <httpunit-
[email protected]>
Date sent: Tue, 25 Mar 2008 11:21:51 +0000
Subject: Re: [Httpunit-develop] Problems with IFrames
Send reply to: Discussion of use and development of HttpUnit <httpunit-
[email protected]>
<httpunit-develop.lists.sourceforge.net>
<mailto:[email protected]?subject=unsubscribe>
<mailto:[email protected]?subject=subscribe>
>
> No, not really. No error message if i load the lower frame and set the form values (username and password) and then submit the form. It seems like it keep loading the same page. Does not load the page that should display after the user is logged in.
>
> Is there something im doing wrong?
>
> Following is the code snippet of various pages.
>
> //Login.html (main page that is loaded - this page embed the IFrame).
>
> <html><Head><Script><!--
> function SetLoginForm(name, password, Submit) { document.loginForm.name.value = name; document.loginForm.password.value = password; document.loginForm.submit();}--></Script></Head>
> <Body><Form name="loginForm" action="/LoginController" method="Post">
> <input type="hidden" name="name" value="" /><input type="hidden" name="password" value="" /></Form>
> <Center><IFrame name="login" id="login" src="LoginDialog.html" /></Center></Body>
> </html>
>
> // LoginDialog.html - IFrame
>
> <html><Head><Script><!--
> function SubmitToParent(action) { parent.SetLoginForm(document.submit_to_parent.name.value,document.submit_to_parent.password.value);
> }--></Script></Head>
> <Body><Form id=f1 name="submit_to_parent" method="Post">
> <input type="text" name="name" value="" /><input type="text" name="password" value="" />
> <input type="submit" name="Ok" value="login" onClick="SubmitToParent('Submit')" /></Form>
> </Body>
> </html>
>
> // Login.java - HttpUnit Testcase
> public void testLogin() {
> this.response = conversation.getCurrentPage()' WebResponse bottomFrame = conversation.getFrameContents("login"); // load the <Iframe> WebForm form = bottomFrame.getFormWithName("submit_to_parent"); form.setParameter("user","aa"); form.setParameter("password","xx");
this.response = form.submit(); // This response contains the same page, does not log the user in. Load the same //page}
>
> Thanks.
>
> Regds,
>
> Al.
>
>
> Date: Sun, 23 Mar 2008 13:22:01 -0400From: [email protected]: [email protected]: Re: [Httpunit-develop] Problems with IFrames
> Are you getting any error messages?On Mar 21, 2008, at 10:56 AM, Allwyn D'souza wrote:
>
> Hi Guys, Im using HttpUnit to write test cases. My web application uses <Iframes> to login to the application. To simplify, i have a login page. This page has a javascript function (loginIntoApp) that accepts username and password as parameters to the method. This method sets the username and password to the hidden
field and then post the form to a given action. The login page embeds an <IFrame> called "ChildFrame.html". This frame has an html form that accepts "username" and "password" from the user. On the submit of this form, a javascript is called which in turn calls the javascript of its parent (loginIntoApp),
mentioned above. I tried different things to write a test cases that login into the app, but i could not login. It works fine if i login using the web browser. Any suggestions or solution would be appreciated? Thanks. Al.
>
> When was the last time you saw your friends or family? Free unlimited Video Calls from Windows Live Messenger - download it here for FREE! Click here! -------------------------------------------------------------------------This SF.net email is sponsored by: MicrosoftDefy all challenges. Microsoft(R) Visual Studio 2008.http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/_______________________________________________Httpunit-develop
mailing [email protected]://lists.sourceforge.net/lists/listinfo/httpunit-develop
> _________________________________________________________________
> Download the new 2008 version of Windows Live Messenger here, FREE!
> http://get.live.com/messenger/overview
BITPlan - smart solutions
Pater-Delp-Str. 1, D-47877 Willich Schiefbahn
Tel. +49 1805 - BITPLAN / +49 1805 248 752, Fax +49 2154 811-481
Web: http://www.bitplan.de
bitplan GmbH, Willich - HRB 6820 Krefeld, VAT-ID: 10258040548, Geschäftsführer: Wolfgang Fahl
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop