01: /*
02: * Created on 15.10.2004
03: *
04: * TODO To change the template for this generated file go to
05: * Window - Preferences - Java - Code Style - Code Templates
06: */
07: package org.jzonic.webtester;
08:
09: import junit.framework.TestCase;
10:
11: /**
12: * @author Mecky
13: *
14: * TODO To change the template for this generated type comment go to
15: * Window - Preferences - Java - Code Style - Code Templates
16: */
17: public class WebTesterTest extends TestCase {
18:
19: public void testSimpleTest() {
20: WebTester tester = new WebTester("");
21: tester.parseLine("get_html | http://www.google.de");
22: tester.parseLine("check_text | Anmelden");
23: WebTestResult result = tester.runTest();
24: assertTrue(result.isSuccess());
25: }
26:
27: public void testSimpleTestWithError() {
28: WebTester tester = new WebTester("Google Test");
29: tester.parseLine("get_html | http://www.google.de");
30: tester.parseLine("check_text | Gugle Toolbar");
31: WebTestResult result = tester.runTest();
32: assertTrue(!result.isSuccess());
33: assertNotNull(result.getErrorNode());
34: assertEquals(
35: "check_text: The text:'Gugle Toolbar' was not found",
36: result.getErrorNode().getErrorMessage());
37: }
38:
39: public void testSimpleTestWithSubmit() {
40: WebTester tester = new WebTester("Google Test");
41: tester.parseLine("get_html | http://www.google.de");
42: tester.parseLine("select_form | 0 ");
43: tester.parseLine("set_textfield | q = jConfig");
44: tester.parseLine("submit_form | btnG");
45: WebTestResult result = tester.runTest();
46: assertTrue(result.isSuccess());
47: assertNull(result.getErrorNode());
48: }
49:
50: public void testSimpleTestWithPrefix() {
51: WebTester tester = new WebTester("Google Test");
52: tester.parseLine("set_url_prefix | http://www.google.de");
53: tester.parseLine("get_html | / ");
54: tester.parseLine("select_form | 0 ");
55: tester.parseLine("set_textfield | q = jConfig");
56: tester.parseLine("submit_form | btnG");
57: WebTestResult result = tester.runTest();
58: assertTrue(result.isSuccess());
59: assertNull(result.getErrorNode());
60: }
61: }
|