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;
}
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;
}