Problem to Navigating on Next Page[Handle Java Script]
"Vipul khalasi" <[email protected]>
| Newsgroups | gmane.comp.web.httpunit.devel |
|---|---|
| Message-ID | <[email protected]> |
hi sir,
i have problem i m not be able to pass the right value and try to handle
javascript but problem is it give many error to handle so lease give proper
help how to handle javaScript
> One more thing is that on the Get It but OnCilck event java script is fire
so on next page query not get right value...
import com.meterware.servletunit.*;
import com.meterware.httpunit.*;
import junit.framework.*;
import java.net.*;
import java.io.*;
import java.util.*;
import java.lang.String;
import java.sql.*;
import com.meterware.httpunit.WebForm.Scriptable;
import org.xml.sax.*;
import com.meterware.httpunit.scripting.ScriptableDelegate;
public class index extends ScriptableDelegate{
public index(){}
public void testTrainofDay(String src,String dts,String cls,String
day,String month) throws Exception{
WebConversation wc = new WebConversation();
WebRequest request = new GetMethodWebRequest("
http://www.indianrail.gov.in/");
// WebRequest request = new GetMethodWebRequest("
http://www.indianrail.gov.in/inet_metro_trns.html");
WebResponse resp = wc.getResponse( request );
resp = resp.getSubframeContents("top");
// assertNotNull("got the engine frame",resp);
WebLink[] links = resp.getLinks();
if(links.length >0 ){
try{
WebLink httpunitLink = resp.getFirstMatchingLink(
WebLink.MATCH_CONTAINED_TEXT, "Imp. Stations");
resp = httpunitLink.click();
System.out.println( "TheTrains between Imp. Stations page
contains " + resp.getLinks().length + " links" );
}catch(Exception e){
System.out.println("No such A link found");
}
}
testTrainofDay(resp,src,dts,cls,day,month);
}
public void testTrainofDay(WebResponse resp,String src,String dts,String
cls,String day,String month) throws SAXException,Exception{
try{
//HttpUnitOptions.setScriptingEnabled(true);
System.out.println(resp.getURL());
String elm[]=resp.getElementNames();
WebForm form1 = resp.getForms()[0];
System.out.println("form1.length:"+resp.getForms().length+" Action
:"+form1.getAction() );
// assertNotNull("Form Found",form1);
System.out.println(src+" : "+dts+" : "+cls);
//public java.lang.String runScript(java.lang.Stringlanguage,
java.lang.String scriptText)
if(doEvent("validatemonth()")){
System.out.println("ScriptableDelegate()
:"+runScript("JAVA","validatemonth()"));
}
form1.setParameter( "lccp_src_stncode",src);
form1.setParameter( "lccp_dstn_stncode",dts);
form1.setParameter( "lccp_classopt",cls);
form1.setParameter( "lccp_day",day);
form1.setParameter( "lccp_month",month);
//SubmitButton saveButton = form1.getSubmitButton("Get
It");
resp = form1.submit(form1.getSubmitButton("Get It"));
//resp = form1.submit(saveButton);
if(doEvent("return validatemonth()")){
System.out.println("ScriptableDelegate()
:"+runScript("JAVA","return validatemonth()"));
}
System.out.println(resp.getText());
System.out.println(resp.getURL());
HttpUnitOptions.setScriptingEnabled(false);
// assertEquals(resp.getTitle(),"Know Trains Between A
Source Destination Pair");
System.out.println("Know Trains Between A Source
Destination Pair");
}catch(Exception e){
System.out.println("public void testTrainofDay(WebResponse
resp,String src,String dts,String cls,String day,String month)");
e.printStackTrace();
}
//testGetAvailability11(resp,d_day,d_month,d_Tno,q);
}
public static void main (String[] args){
try{
HttpUnitOptions.setScriptingEnabled(false);
index ftc = new index();
ftc.testTrainofDay(args[0].toString(),args[1].toString(),args[2].toString(),args[3].toString(),args[4].toString());
}catch(Exception e){
e.printStackTrace();
}
}
}
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Httpunit-develop mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/httpunit-develop