Hi Julien...... thank you so much for your response and taking the time
to help me...
I'm now using an ide (intellij idea) to develop my simple tests. I've
followed your instructions (which include removing Tester = new
WebTester) but am still getting problems - namely the following:
/opt/jdk1.5.0_04/bin/java -Didea.launcher.port=7532
-Didea.launcher.bin.path=/home/hanif/idea-6148/bin
-Dfile.encoding=US-ASCII -classpath
/opt/jre1.5.0_04/lib/jce.jar:/opt/jre1.5.0_04/lib/javaws.jar:/opt/jre1.5.0_04/lib/deploy.jar:/opt/jre1.5.0_04/lib/jsse.jar:/opt/jre1.5.0_04/lib/charsets.jar:/opt/jre1.5.0_04/lib/plugin.jar:/opt/jre1.5.0_04/lib/rt.jar:/opt/jdk1.5.0_04/lib/tools.jar:/opt/jre1.5.0_04/lib/ext/sunjce_provider.jar:/opt/jre1.5.0_04/lib/ext/sunpkcs11.jar:/opt/jre1.5.0_04/lib/ext/dnsns.jar:/opt/jre1.5.0_04/lib/ext/localedata.jar:/home/hanif/IdeaProjects/testHanif/classes/test/testHanif:/home/hanif/IdeaProjects/testHanif/classes/production/testHanif:/home/hanif/Java/jwebunit-1/jwebunit-core-1.4-rc3.jar:/home/hanif/Java/jwebunit-1/jwebunit-htmlunit-plugin-1.4-rc3.jar:/home/hanif/Java/jwebunit-1/lib:/home/hanif/Java/jwebunit-1/lib/js-1.6R2.jar:/home/hanif/Java/jwebunit-1/lib/htmlunit-1.10.jar:/home/hanif/Java/jwebunit-1/lib/xml-apis-1.3.02.jar:/home/hanif/Java/jwebunit-1/lib/xom-1.0b3.jar:/home/hanif/Java/jwebunit-1/lib/jdom-1.0.jar:/home/hanif/Java/jwebunit-1/lib/xalan-2.6.0.jar:/home/hanif/Java/jwebuni
t-1/lib/xercesImpl-2.6.2.jar:/home/hanif/Java/jwebunit-1/lib/nekohtml-0.9.5.jar:/home/hanif/Java/jwebunit-1/lib/commons-lang-2.1.jar:/home/hanif/Java/jwebunit-1/lib/commons-codec-1.3.jar:/home/hanif/Java/jwebunit-1/lib/commons-httpclient-3.0.1.jar:/home/hanif/Java/jwebunit-1/lib/commons-logging-1.1.jar:/home/hanif/Java/jwebunit-1/lib/tagsoup-0.9.7.jar:/home/hanif/Java/jwebunit-1/lib/regexp-1.3.jar:/home/hanif/Java/jwebunit-1/lib/avalon-framework-4.1.3.jar:/home/hanif/Java/jwebunit-1/lib/icu4j-2.6.1.jar:/home/hanif/Java/jwebunit-1/lib/junit-3.8.2.jar:/home/hanif/Java/jwebunit-1/lib/jaxen-1.1-beta-11.jar:/home/hanif/Java/jwebunit-1/lib/log4j-1.2.12.jar:/home/hanif/Java/jwebunit-1/lib/dom4j-1.6.1.jar:/home/hanif/Java/jwebunit-1/lib/xmlParserAPIs-2.6.2.jar:/home/hanif/Java/jwebunit-1/lib/servlet-api-2.4.jar:/home/hanif/Java/jwebunit-1/lib/commons-io-1.2.jar:/home/hanif/Java/jwebunit-1/lib/commons-collections-3.2.jar:/home/hanif/Java/jwebunit-1/lib/logkit-1.0.1.jar:/home/hanif/ide
a-6148/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain
newline.haniftest
Exception in thread "main" java.lang.NullPointerException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:90)
Process finished with exit code 1
For the life of me, I can't figure it out.
I am totally new to Java as well!
I've attached my recent java file....... if you have the time.......
thank you so much Julien!
Hanif
Julien HENRY wrote:
Hi Hanif,
I made some comments in your code (in red). JWebUnit 1.3+ now uses
HtmlUnit instead of HttpUnit. You should remove all HttpUnit
references, and try to not add HtmlUnit dependencies. This way, when a
new plugin will appear (for example for Selenium), you just have to
change setTestingEngineKey().
HtmlUnit deals much better with JavaScript, but is not perfect. You
can try to disable JavaScript for one test by using
setScriptingEnabled(false);
// problematic code
setScriptingEnabled(true);
May I suggest you should write JUnit-like tests.
++
Julien
/**
* Created by IntelliJ IDEA.
* User: hanif
* Date: Jan 29, 2007
* Time: 5:07:16 PM
* To change this template use File | Settings | File Templates.
*/
/* if this stops working unexpectedly here are some reasons why:
* 1. the product numbers are hard-coded in and the product may have
been removed from the site
* 2. the exp. year on the visa card has passed.
* 3. catagory used in shopByCatTest may no longer exist
* 4.
*/
package newline;
import net.sourceforge.jwebunit.junit.WebTestCase;
import net.sourceforge.jwebunit.util.TestingEngineRegistry;
import javax.net.ssl.HostnameVerifier;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLSession;
import java.net.URL;
public class haniftest extends WebTestCase {
public haniftest(String homepage) {
super(homepage);
setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
getTestContext().setBaseUrl(homepage);
}
// public void setUp() throws Exception {
//
setTestingEngineKey(TestingEngineRegistry.TESTING_ENGINE_HTMLUNIT);
// String homepage;
// homepage = "http://ellen.hanif.newline.projects.novator.com/";
// System.out.println("Running test with base " + homepage);
// getTestContext().setBaseUrl(homepage);
// }
static public class testHostnameVerifier implements HostnameVerifier {
public testHostnameVerifier() { super(); }
public boolean verify(String hostname, SSLSession session) {
return true; }
}
public void testInfoPage() {
beginAt("/");
}
// adds a product identified by sku
public void productAddTest(String prod_sku, String prod_name) {
// this should run from any starting point, because it does a
search by the sku
setTextField("keywords1", prod_sku );
submit();
clickLinkWithText(prod_name);
assertSubmitButtonPresent("add_to_cart");
submit("add_to_cart");
submit("ce_submit");
}
public void main( String args[] ) throws
java.net.MalformedURLException, java.io.IOException {
HttpsURLConnection con = (HttpsURLConnection) new
URL("https://www.novator.com").openConnection();
con.setDefaultHostnameVerifier(new testHostnameVerifier());
System.out.println("Instanciating object");
String homepage;
homepage = "http://ellen.hanif.newline.projects.novator.com/";
System.out.println("Running test with base " + homepage);
haniftest test = new haniftest(homepage);
try {
long start;
//test.testInfoPage();
System.out.print("addtocart from product details (ELCFWATCH)
.......");
start = System.currentTimeMillis();
//test.productAddTest("ELCFWATCH", "The Ellen DeGeneres Show
Watch with Three Interchangeable Straps");
System.out.println(" took " + (System.currentTimeMillis() -
start) + " ms");
} catch( Exception e ){
System.out.println("A TEST FAILED: " + e);
}
}
}
-------------------------------------------------------------------------
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
_______________________________________________
JWebUnit-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jwebunit-users