Getting the frame elements using HttpUnit

  • Thread starter Avishay Balderman
  • Start date
A

Avishay Balderman

Hi

Here are the steps I do before I get the below frameset:

1) I am loging into a web application using user and password.

2) Upon a succful login I click on a specific link.

3) As a response I get the below frameset

I would like to find a way to manipulate foo.asp.

You can find my source code below.

Please help.

Thanks

Avishay

<a name="top">

<frameset cols="14%,*">

<frameset rows="15%,*">

<frame name="Right" src="Right.html" marginwidth="0" marginheight="0"
scrolling="no" frameborder="0">

<frameset rows="100%,*">

<frame name="Left" src="Left.asp" marginwidth="0" marginheight="0"
scrolling="Auto" frameborder="0" noresize>

<frame name="Down" src="Down.html" marginwidth="0" marginheight="5%"
scrolling="no" frameborder="0">

</frameset>

</frameset>

<frameset rows="15%,*">

<frame name="top1" src="top.asp" marginwidth="" marginheight="20"
scrolling="no" frameborder="0">

<frame name="Main" src="foo.asp" marginwidth="0" marginheight="0"
scrolling="auto" frameborder="0">

</frameset>

</frameset>

My source code:

import com.meterware.httpunit.*;

public class Main

{

public static void main(String[] args)

{

dbg("Connecting MIS..");

try

{

WebConversation conversation = new WebConversation();

WebRequest request = new GetMethodWebRequest(MIS_LOGIN_PAGE);

WebResponse response = conversation.getResponse(request);

WebForm forms[] = response.getForms();

WebForm loginForm = forms[0];

loginForm.setParameter(MIS_LOGIN_FORM_USER, MIS_USER);

loginForm.setParameter(MIS_LOGIN_FORM_PWD, MIS_PWD);

response = loginForm.submit();

boolean loginOK =
!response.getURL().toString().equalsIgnoreCase(MIS_LOGIN_PAGE_ERR);

if(!loginOK)

{

err("login fail");

System.exit(1);

}

dbg("After login URL: " + response.getURL());

dbg("Login OK");

WebLink links [] = response.getLinks();

int i;

response = null;

for(i = 0; i < links.length; i++)

{

if(links.getURLString().indexOf(TIME_URL) != -1)

{

dbg("The link we click: " + links.getURLString());

//

// Click the link

//

response = links.click();

break;

}

}

if(response == null)

{

err("Could not find the link to the reporting page");

System.exit(2);

}

dbg("Response Text: " + response.getText());

dbg("Response Message: " + response.getResponseMessage());

//

// Find the frame we need

// Inerst here code to find the frame..

//

WebForm reportFrom = response.getFormWithName(MIS_REPORT_FORM);

if(reportFrom != null)

{

Button comButton = reportFrom.getButtonWithID(MIS_REPORT_FORM_COMPLETE);

if(comButton != null)

{

comButton.click();

}

}

}

catch(Exception e)

{

System.out.println(e.getMessage());

e.printStackTrace();

}

}

private static void err(String str)

{

System.out.println("ERR > " + str);

}

private static void dbg(String str)

{

if(DBG)

{

System.out.println("DBG > " + str);

}

}

private static boolean DBG = true;

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Frame Changes it's fixed size 0
httpUnit 1
Hyperlink & Frames 1
Getting the width of a frame 4
Refer to <div> from separate <frame> 2
HTML frame tag 2
HttpUnit Tutorial 0
Frame Resizing 4

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,059
Latest member
cryptoseoagencies

Latest Threads

Top