View Javadoc

1   /*
2       Jameleon - An automation testing tool..
3       Copyright (C) 2003 Christian W. Hargraves (engrean@hotmail.com)
4       
5       This library is free software; you can redistribute it and/or
6       modify it under the terms of the GNU Lesser General Public
7       License as published by the Free Software Foundation; either
8       version 2.1 of the License, or (at your option) any later version.
9   
10      This library is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13      Lesser General Public License for more details.
14  
15      You should have received a copy of the GNU Lesser General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19  package net.sf.jameleon.plugin.jwebunit;
20  
21  import net.sf.jameleon.util.JameleonUtility;
22  import net.sf.jameleon.util.AssertLevel;
23  import net.sf.jameleon.util.StateStorer;
24  import net.sf.jameleon.result.HttpRequestResult;
25  import net.sf.jameleon.function.FunctionTag;
26  
27  import com.meterware.httpunit.WebClientListener;
28  import com.meterware.httpunit.WebClient;
29  import com.meterware.httpunit.WebRequest;
30  import com.meterware.httpunit.WebResponse;
31  
32  import net.sourceforge.jwebunit.ExpectedTable;
33  import net.sourceforge.jwebunit.HttpUnitDialog;
34  import net.sourceforge.jwebunit.TestContext;
35  import net.sourceforge.jwebunit.WebTester;
36  
37  import java.io.File;
38  import java.io.IOException;
39  import java.io.PrintStream;
40  
41  /***
42   * An implementation of the JWebUnit plugin for a FunctionTag. All methods in the <code>WebTester</code> class provided
43   * by the JWebUnit API is wrapped for easy coding and statical reporting.
44   * <br>
45   * <br>
46   * For function points that will always be used to start the test case, the begin() method should be called first.
47   */
48  public abstract class HttpFunctionTag extends FunctionTag {
49  
50      /***
51       * The session that is to be shared among all TestSteps encapsulated within a TestCase
52       */
53      protected WebTester session;
54      /***
55       * The start time of a request
56       */
57      protected long requestTime;
58  
59      /***
60       * A Client Listener used for logging. This can't be used since the Dialog doesn't get instaniated until after the first request.
61       */
62      protected WebClientListener listener = 
63      new WebClientListener() {
64          public void requestSent(WebClient src, WebRequest req) {
65              requestTime = System.currentTimeMillis();
66          }
67  
68          public void responseReceived(WebClient src, WebResponse res) {
69              long responseTime = System.currentTimeMillis() - requestTime;
70              HttpRequestResult result = new HttpRequestResult(res.getURL().toString(), responseTime,res.getResponseCode(), functionId);
71              log.debug(result.toXML());
72              state.eventOccured(StateStorer.ON_STATE_CHANGE_EVENT);
73          }
74      };
75  
76      /***
77       * Default constructor -- Does nothing
78       */
79      public HttpFunctionTag(){
80          super();
81      }
82  
83      /***
84       * Gets the references of the session and the test results from the parent TestCase
85       * This method gets called once all attributes are set from the macro language. Any required
86       * setup should go here.
87       */
88      public void setupEnvironment(){
89          super.setupEnvironment();
90          Object obj =  findAncestorWithClass(HttpSessionTag.class);
91          HttpSessionTag s = null;
92          if (obj instanceof HttpSessionTag) {
93              s = (HttpSessionTag)obj;
94          }else{
95              throw new ClassCastException("Can only execute the JWebUnit function tag under the JWebUnit session tag ( http-session )! "+
96                                           "Please change the session tag surrounding function point "+getClass().getName());
97          }
98          session = s.getHttpSession();
99      }
100 
101     /***
102      * Called when the function is done being executed. Use to clean up resources created in the setup method.
103      */
104     public void pluginTearDown() {
105         session = null;
106     }
107 
108     /*****************************************************************************************
109      *Start of Wrapper Methods
110     ****************************************************************************************/
111                                                                                              
112     /***
113      * Provides access to the httpunit wrapper for subclasses - in case functionality not
114      * yet wrappered required by test.
115      *
116      * @return HttpUnitDialog instance used to wrapper httpunit conversation.
117      */
118     public HttpUnitDialog getDialog() {
119         return session.getDialog();
120     }
121 
122     /***
123      * Provide access to test context.
124      *
125      * @return TestContext
126      */
127     public TestContext getTestContext() {
128         return session.getTestContext();
129     }
130 
131     /***
132      * Sets the baseUrl to it's property setting based on the application name, 
133      * and environment.
134      */
135     public void setBaseUrl(){
136         session.getTestContext().setBaseUrl((String)context.getVariable("baseUrl"));
137     }
138 
139     /***
140      * Begin conversation at a url relative to the application root.
141      * This uses a variable stored in the context called beginAt
142      */
143     public void begin() {
144         setBaseUrl();
145         recordHttpResultBlock(new Runnable(){
146                 public void run(){
147                     session.beginAt((String)context.getVariable("beginAt"));
148                 }
149         });
150     }
151 
152     /***
153      * Begin conversation at a url relative to the application root.
154      *
155      * @param relativeURL
156      */
157     public void beginAt(final String relativeURL) {
158         recordHttpResultBlock(new Runnable(){
159                 public void run(){
160                     session.beginAt(relativeURL);
161                 }
162         });
163     }
164 
165     /***
166      * Runs the run method of a Runnable and records the time taken to execute the code block
167      * @param r - The block of code you want executed ( defined in the run() method ).
168      */
169     protected void recordHttpResultBlock(Runnable r){
170         long start = System.currentTimeMillis();
171         try{
172             r.run();
173         }catch(Exception e){
174             state.eventOccured(StateStorer.ON_ERROR_EVENT);
175         }finally{
176             state.eventOccured(StateStorer.ON_STATE_CHANGE_EVENT);
177             recordResult(start,session.getDialog().getResponse().getURL().toString());
178             session.getDialog().getWebClient().addClientListener(listener);
179         }
180     }
181 
182     /***
183      * Helper method
184      */
185     private void recordResult(long startTime, String url){
186         long responseTime = System.currentTimeMillis() - startTime;
187         HttpRequestResult result = new HttpRequestResult(url,responseTime,session.getDialog().getResponse().getResponseCode(),functionId);
188         log.debug(result.toXML());
189     }
190 
191     /***
192      * Return the value of a web resource based on its key. This translates to a
193      * property file lookup with the locale based on the current TestContext.
194      *
195      * @param key name of the web resource.
196      * @return value of the web resource, encoded according to TestContext.
197      */
198     public String getMessage(String key) {
199         return session.getMessage(key);
200     }
201 
202     //Storable Methods
203 
204     public void store(String fName, int event) throws IOException{
205         try{
206             if (session.getDialog() != null){
207                 String html = session.getDialog().getResponseText();
208                 File f = new File(fName+".html");
209                 JameleonUtility.recordResultsToFile(f, html);
210                 getFunctionResults().setErrorFile(f);
211             }
212         }catch(RuntimeException re){
213             throw new IOException(JameleonUtility.createErrMsg("Unable to get response to store to file:\n\r "+JameleonUtility.getStack(re)));
214         }
215     }
216 
217     //End Storable Methods.
218 
219     //JWebUnit Assertions
220     /***
221      * Assert title of current html page in conversation matches an expected value.
222      *
223      * @param title expected title value
224      */
225     public void assertTitleEquals(final String title) {
226         int assertLevel = AssertLevel.NO_LEVEL;
227         assertTitleEquals(title, assertLevel);
228     }
229 
230     /***
231      * Assert title of current html page in conversation matches an expected value.
232      *
233      * @param title expected title value
234      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
235      */
236     public void assertTitleEquals(final String title, int assertLevel) {
237         assertMethodWithLevel(new Runnable() {
238                 public void run() {
239                     session.assertTitleEquals(title);
240                 }
241         },assertLevel);
242     }
243 
244     /***
245      * Assert title of current html page matches the value of a specified web resource.
246      *
247      * @param titleKey web resource key for title
248      */
249     public void assertTitleEqualsKey(final String titleKey) {
250         int assertLevel = AssertLevel.NO_LEVEL;
251         assertTitleEqualsKey(titleKey, assertLevel);
252     }
253 
254     /***
255      * Assert title of current html page matches the value of a specified web resource.
256      *
257      * @param titleKey web resource key for title
258      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
259      */
260     public void assertTitleEqualsKey(final String titleKey, int assertLevel) {
261         assertMethodWithLevel(new Runnable() {
262                 public void run() {
263                     session.assertTitleEqualsKey(titleKey);
264                 }
265         },assertLevel);
266     }
267 
268     /***
269      * Assert that a web resource's value is present.
270      *
271      * @param key web resource name
272      */
273     public void assertKeyPresent(final String key) {
274         int assertLevel = AssertLevel.NO_LEVEL;
275         assertKeyPresent(key, assertLevel);
276     }
277 
278     /***
279      * Assert that a web resource's value is present.
280      *
281      * @param key web resource name
282      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
283      */
284     public void assertKeyPresent(final String key, int assertLevel) {
285         assertMethodWithLevel(new Runnable() {
286                 public void run() {
287                     session.assertKeyPresent(key);
288                 }
289         }, assertLevel);
290     }
291 
292     /***
293      * Assert that supplied text is present.
294      *
295      * @param text
296      */
297     public void assertTextPresent(final String text) {
298         int assertLevel = AssertLevel.NO_LEVEL;
299         assertTextPresent(text, assertLevel);
300     }
301 
302     /***
303      * Assert that supplied text is present.
304      *
305      * @param text
306      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
307      */
308     public void assertTextPresent(final String text, int assertLevel) {
309         assertMethodWithLevel(new Runnable() {
310                 public void run() {
311                     session.assertTextPresent(text);
312                 }
313         }, assertLevel);
314     }
315 
316     /***
317      * Assert that a web resource's value is not present.
318      *
319      * @param key web resource name
320      */
321     public void assertKeyNotPresent(final String key) {
322         int assertLevel = AssertLevel.NO_LEVEL;
323         assertKeyNotPresent(key, assertLevel);
324     }
325 
326     /***
327      * Assert that a web resource's value is not present.
328      *
329      * @param key web resource name
330      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
331      */
332     public void assertKeyNotPresent(final String key, int assertLevel) {
333         assertMethodWithLevel(new Runnable() {
334                 public void run() {
335                     session.assertKeyNotPresent(key);
336                 }
337         }, assertLevel);
338     }
339 
340     /***
341      * Assert that supplied text is not present.
342      *
343      * @param text
344      */
345     public void assertTextNotPresent(final String text) {
346         int assertLevel = AssertLevel.NO_LEVEL;
347         assertTextNotPresent(text, assertLevel);
348     }
349 
350     /***
351      * Assert that supplied text is not present.
352      *
353      * @param text
354      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
355      */
356     public void assertTextNotPresent(final String text, int assertLevel) {
357         assertMethodWithLevel(new Runnable() {
358                 public void run() {
359                     session.assertTextNotPresent(text);
360                 }
361         }, assertLevel);
362     }
363 
364     /***
365      * Assert that a table with a given summary or id value is present.
366      *
367      * @param tableSummaryOrId summary or id attribute value of table
368      */
369     public void assertTablePresent(final String tableSummaryOrId) {
370         int assertLevel = AssertLevel.NO_LEVEL;
371         assertTablePresent(tableSummaryOrId, assertLevel);
372     }
373 
374     /***
375      * Assert that a table with a given summary or id value is present.
376      *
377      * @param tableSummaryOrId summary or id attribute value of table
378      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
379      */
380     public void assertTablePresent(final String tableSummaryOrId, int assertLevel) {
381         assertMethodWithLevel(new Runnable() {
382                 public void run() {
383                     session.assertTablePresent(tableSummaryOrId);
384                 }
385         }, assertLevel);
386     }
387 
388     /***
389      * Assert that a table with a given summary or id value is not present.
390      *
391      * @param tableSummaryOrId summary or id attribute value of table
392      */
393     public void assertTableNotPresent(final String tableSummaryOrId) {
394         int assertLevel = AssertLevel.NO_LEVEL;
395         assertTableNotPresent(tableSummaryOrId, assertLevel);
396     }
397 
398     /***
399      * Assert that a table with a given summary or id value is not present.
400      *
401      * @param tableSummaryOrId summary or id attribute value of table
402      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
403      */
404     public void assertTableNotPresent(final String tableSummaryOrId, int assertLevel) {
405         assertMethodWithLevel(new Runnable() {
406                 public void run() {
407                     session.assertTableNotPresent(tableSummaryOrId);
408                 }
409         }, assertLevel);
410     }
411 
412     /***
413      * Assert that the value of a given web resource is present in a specific table.
414      *
415      * @param tableSummaryOrId summary or id attribute value of table
416      * @param key web resource name
417      */
418     public void assertKeyInTable(final String tableSummaryOrId, final String key) {
419         int assertLevel = AssertLevel.NO_LEVEL;
420         assertKeyInTable(tableSummaryOrId, key, assertLevel);
421     }
422 
423     /***
424      * Assert that the value of a given web resource is present in a specific table.
425      *
426      * @param tableSummaryOrId summary or id attribute value of table
427      * @param key web resource name
428      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
429      */
430     public void assertKeyInTable(final String tableSummaryOrId, final String key, int assertLevel) {
431         assertMethodWithLevel(new Runnable() {
432                 public void run() {
433                     session.assertKeyInTable(tableSummaryOrId,key);
434                 }
435         }, assertLevel);
436     }
437 
438     /***
439      * Assert that supplied text is present in a specific table.
440      *
441      * @param tableSummaryOrId summary or id attribute value of table
442      * @param text
443      */
444     public void assertTextInTable(final String tableSummaryOrId, final String text) {
445         int assertLevel = AssertLevel.NO_LEVEL;
446         assertTextInTable(tableSummaryOrId, text, assertLevel);
447     }
448 
449     /***
450      * Assert that supplied text is present in a specific table.
451      *
452      * @param tableSummaryOrId summary or id attribute value of table
453      * @param text
454      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
455      */
456     public void assertTextInTable(final String tableSummaryOrId, final String text, int assertLevel) {
457         assertMethodWithLevel(new Runnable() {
458                 public void run() {
459                     session.assertTextInTable(tableSummaryOrId,text);
460                 }
461         }, assertLevel);
462     }
463 
464     /***
465      * Assert that the values of a set of web resources are all present in a specific table.
466      *
467      * @param tableSummaryOrId summary or id attribute value of table
468      * @param keys Array of web resource names.
469      */
470     public void assertKeysInTable(final String tableSummaryOrId, final String[] keys) {
471         int assertLevel = AssertLevel.NO_LEVEL;
472         assertKeysInTable(tableSummaryOrId, keys, assertLevel);
473     }
474 
475     /***
476      * Assert that the values of a set of web resources are all present in a specific table.
477      *
478      * @param tableSummaryOrId summary or id attribute value of table
479      * @param keys Array of web resource names.
480      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
481      */
482     public void assertKeysInTable(final String tableSummaryOrId, final String[] keys, int assertLevel) {
483         assertMethodWithLevel(new Runnable() {
484                 public void run() {
485                     session.assertTextInTable(tableSummaryOrId,keys);
486                 }
487         }, assertLevel);
488     }
489 
490     /***
491      * Assert that a set of text values are all present in a specific table.
492      *
493      * @param tableSummaryOrId summary or id attribute value of table
494      * @param text Array of expected text values.
495      */
496     public void assertTextInTable(final String tableSummaryOrId, final String[] text) {
497         int assertLevel = AssertLevel.NO_LEVEL;
498         assertTextInTable(tableSummaryOrId, text, assertLevel);
499     }
500 
501     /***
502      * Assert that a set of text values are all present in a specific table.
503      *
504      * @param tableSummaryOrId summary or id attribute value of table
505      * @param text Array of expected text values.
506      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
507      */
508     public void assertTextInTable(final String tableSummaryOrId, final String[] text, int assertLevel) {
509         assertMethodWithLevel(new Runnable() {
510                 public void run() {
511                     session.assertTextInTable(tableSummaryOrId,text);
512                 }
513         }, assertLevel);
514     }
515 
516     /***
517      * Assert that the value of a given web resource is not present in a specific table.
518      *
519      * @param tableSummaryOrId summary or id attribute value of table
520      * @param key web resource name
521      */
522     public void assertKeyNotInTable(final String tableSummaryOrId, final String key) {
523         int assertLevel = AssertLevel.NO_LEVEL;
524         assertKeyNotInTable(tableSummaryOrId, key, assertLevel);
525     }
526 
527     /***
528      * Assert that the value of a given web resource is not present in a specific table.
529      *
530      * @param tableSummaryOrId summary or id attribute value of table
531      * @param key web resource name
532      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
533      */
534     public void assertKeyNotInTable(final String tableSummaryOrId, final String key, int assertLevel) {
535         assertMethodWithLevel(new Runnable() {
536                 public void run() {
537                     session.assertKeyNotInTable(tableSummaryOrId,key);
538                 }
539         }, assertLevel);
540     }
541 
542     /***
543      * Assert that supplied text is not present in a specific table.
544      *
545      * @param tableSummaryOrId summary or id attribute value of table
546      * @param text
547      */
548     public void assertTextNotInTable(final String tableSummaryOrId, final String text) {
549         int assertLevel = AssertLevel.NO_LEVEL;
550         assertTextNotInTable(tableSummaryOrId, text, assertLevel);
551     }
552 
553     /***
554      * Assert that supplied text is not present in a specific table.
555      *
556      * @param tableSummaryOrId summary or id attribute value of table
557      * @param text
558      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
559      */
560     public void assertTextNotInTable(final String tableSummaryOrId, final String text, int assertLevel) {
561         assertMethodWithLevel(new Runnable() {
562                 public void run() {
563                     session.assertTextNotInTable(tableSummaryOrId,text);
564                 }
565         }, assertLevel);
566     }
567 
568     /***
569      * Assert that none of a set of text values are present in a specific table.
570      *
571      * @param tableSummaryOrId summary or id attribute value of table
572      * @param text Array of text values
573      */
574     public void assertTextNotInTable(final String tableSummaryOrId, final String[] text) {
575         int assertLevel = AssertLevel.NO_LEVEL;
576         assertTextNotInTable(tableSummaryOrId, text, assertLevel);
577     }
578 
579     /***
580      * Assert that none of a set of text values are present in a specific table.
581      *
582      * @param tableSummaryOrId summary or id attribute value of table
583      * @param text Array of text values
584      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
585      */
586     public void assertTextNotInTable(final String tableSummaryOrId, final String[] text, int assertLevel) {
587         assertMethodWithLevel(new Runnable() {
588                 public void run() {
589                     session.assertTextNotInTable(tableSummaryOrId,text);
590                 }
591         }, assertLevel);
592     }
593 
594     /***
595      * Assert that a specific table matches an ExpectedTable.
596      *
597      * @param tableSummaryOrId summary or id attribute value of table
598      * @param expectedTable represents expected values (colspan supported).
599      */
600     public void assertTableEquals(final String tableSummaryOrId, final ExpectedTable expectedTable) {
601         int assertLevel = AssertLevel.NO_LEVEL;
602         assertTableEquals(tableSummaryOrId, expectedTable, assertLevel);
603     }
604 
605     /***
606      * Assert that a specific table matches an ExpectedTable.
607      *
608      * @param tableSummaryOrId summary or id attribute value of table
609      * @param expectedTable represents expected values (colspan supported).
610      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
611      */
612     public void assertTableEquals(final String tableSummaryOrId, final ExpectedTable expectedTable, int assertLevel) {
613         assertMethodWithLevel(new Runnable() {
614                 public void run() {
615                     session.assertTableEquals(tableSummaryOrId,expectedTable);
616                 }
617         }, assertLevel);
618     }
619 
620     /***
621      * Assert that a specific table matches a matrix of supplied text values.
622      *
623      * @param tableSummaryOrId summary or id attribute value of table
624      * @param expectedCellValues double dimensional array of expected values
625      */
626     public void assertTableEquals(final String tableSummaryOrId, final String[][] expectedCellValues) {
627         int assertLevel = AssertLevel.NO_LEVEL;
628         assertTableEquals(tableSummaryOrId, expectedCellValues, assertLevel);
629     }
630 
631     /***
632      * Assert that a specific table matches a matrix of supplied text values.
633      *
634      * @param tableSummaryOrId summary or id attribute value of table
635      * @param expectedCellValues double dimensional array of expected values
636      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
637      */
638     public void assertTableEquals(final String tableSummaryOrId, final String[][] expectedCellValues, int assertLevel) {
639         assertMethodWithLevel(new Runnable() {
640                 public void run() {
641                     session.assertTableEquals(tableSummaryOrId,expectedCellValues);
642                 }
643         }, assertLevel);
644     }
645 
646     /***
647      * Assert that a range of rows for a specific table matches a matrix of supplied text values.
648      *
649      * @param tableSummaryOrId summary or id attribute value of table
650      * @param startRow index of start row for comparison
651      * @param expectedTable represents expected values (colspan supported).
652      */
653     public void assertTableRowsEqual(final String tableSummaryOrId, final int startRow, final ExpectedTable expectedTable) {
654         int assertLevel = AssertLevel.NO_LEVEL;
655         assertTableRowsEqual(tableSummaryOrId, startRow, expectedTable, assertLevel);
656     }
657 
658     /***
659      * Assert that a range of rows for a specific table matches a matrix of supplied text values.
660      *
661      * @param tableSummaryOrId summary or id attribute value of table
662      * @param startRow index of start row for comparison
663      * @param expectedTable represents expected values (colspan supported).
664      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
665      */
666     public void assertTableRowsEqual(final String tableSummaryOrId, final int startRow, final ExpectedTable expectedTable, int assertLevel) {
667         assertMethodWithLevel(new Runnable() {
668                 public void run() {
669                     session.assertTableRowsEqual(tableSummaryOrId,startRow,expectedTable);
670                 }
671         }, assertLevel);
672     }
673 
674     /***
675      * Assert that a range of rows for a specific table matches a matrix of supplied text values.
676      *
677      * @param tableSummaryOrId summary or id attribute value of table
678      * @param startRow index of start row for comparison
679      * @param expectedCellValues double dimensional array of expected values
680      */
681     public void assertTableRowsEqual(final String tableSummaryOrId, final int startRow, final String[][] expectedCellValues) {
682         int assertLevel = AssertLevel.NO_LEVEL;
683         assertTableRowsEqual(tableSummaryOrId, startRow, expectedCellValues, assertLevel);
684     }
685 
686     /***
687      * Assert that a range of rows for a specific table matches a matrix of supplied text values.
688      *
689      * @param tableSummaryOrId summary or id attribute value of table
690      * @param startRow index of start row for comparison
691      * @param expectedCellValues double dimensional array of expected values
692      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
693      */
694     public void assertTableRowsEqual(final String tableSummaryOrId, final int startRow, final String[][] expectedCellValues, int assertLevel) {
695         assertMethodWithLevel(new Runnable() {
696                 public void run() {
697                     session.assertTableRowsEqual(tableSummaryOrId,startRow,expectedCellValues);
698                 }
699         }, assertLevel);
700     }
701 
702     /***
703      * Assert that a form input element with a given name is present.
704      *
705      * @param formElementName
706      */
707     public void assertFormElementPresent(final String formElementName) {
708         int assertLevel = AssertLevel.NO_LEVEL;
709         assertFormElementPresent(formElementName, assertLevel);
710     }
711 
712     /***
713      * Assert that a form input element with a given name is present.
714      *
715      * @param formElementName
716      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
717      */
718     public void assertFormElementPresent(final String formElementName, int assertLevel) {
719         assertMethodWithLevel(new Runnable() {
720                 public void run() {
721                     session.assertFormElementPresent(formElementName);
722                 }
723         }, assertLevel);
724     }
725 
726     /***
727      * Assert that a form input element with a given name is not present.
728      *
729      * @param formElementName
730      */
731     public void assertFormElementNotPresent(final String formElementName) {
732         int assertLevel = AssertLevel.NO_LEVEL;
733         assertFormElementNotPresent(formElementName, assertLevel);
734     }
735 
736     /***
737      * Assert that a form input element with a given name is not present.
738      *
739      * @param formElementName
740      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
741      */
742     public void assertFormElementNotPresent(final String formElementName, int assertLevel) {
743         assertMethodWithLevel(new Runnable() {
744                 public void run() {
745                     session.assertFormElementNotPresent(formElementName);
746                 }
747         }, assertLevel);
748     }
749 
750     /***
751      * Assert that a form input element with a given label is present.
752      *
753      * @param formElementLabel label preceding form element.
754      */
755     public void assertFormElementPresentWithLabel(final String formElementLabel) {
756         int assertLevel = AssertLevel.NO_LEVEL;
757         assertFormElementPresentWithLabel(formElementLabel, assertLevel);
758     }
759 
760     /***
761      * Assert that a form input element with a given label is present.
762      *
763      * @param formElementLabel label preceding form element.
764      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
765      */
766     public void assertFormElementPresentWithLabel(final String formElementLabel, int assertLevel) {
767         assertMethodWithLevel(new Runnable() {
768                 public void run() {
769                     session.assertFormElementPresentWithLabel(formElementLabel);
770                 }
771         }, assertLevel);
772     }
773 
774     /***
775      * Assert that a form input element with a given label is not present.
776      *
777      * @param formElementLabel label preceding form element.
778      */
779     public void assertFormElementNotPresentWithLabel(final String formElementLabel) {
780         int assertLevel = AssertLevel.NO_LEVEL;
781         assertFormElementNotPresentWithLabel(formElementLabel, assertLevel);
782     }
783 
784     /***
785      * Assert that a form input element with a given label is not present.
786      *
787      * @param formElementLabel label preceding form element.
788      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
789      */
790     public void assertFormElementNotPresentWithLabel(final String formElementLabel, int assertLevel) {
791         assertMethodWithLevel(new Runnable() {
792                 public void run() {
793                     session.assertFormElementNotPresentWithLabel(formElementLabel);
794                 }
795         }, assertLevel);
796     }
797 
798     /***
799      * Assert that there is a form present.
800      *
801      */
802     public void assertFormPresent() {
803         int assertLevel = AssertLevel.NO_LEVEL;
804         assertFormPresent(assertLevel);
805     }
806 
807     /***
808      * Assert that there is a form present.
809      *
810      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
811      */
812     public void assertFormPresent(int assertLevel) {
813         assertMethodWithLevel(new Runnable() {
814                 public void run() {
815                     session.assertFormPresent();
816                 }
817         }, assertLevel);
818     }
819 
820     /***
821      * Assert that there is a form with the specified name or id present.
822      * @param nameOrID
823      */
824     public void assertFormPresent(final String nameOrID) {
825         int assertLevel = AssertLevel.NO_LEVEL;
826         assertFormPresent(nameOrID, assertLevel);
827     }
828 
829     /***
830      * Assert that there is a form with the specified name or id present.
831      * @param nameOrID
832      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
833      */
834     public void assertFormPresent(final String nameOrID, int assertLevel) {
835         assertMethodWithLevel(new Runnable() {
836                 public void run() {
837                     session.assertFormPresent(nameOrID);
838                 }
839         }, assertLevel);
840     }
841 
842     /***
843      * Assert that a specific form element has an expected value.
844      *
845      * @param formElementName
846      * @param expectedValue
847      */
848     public void assertFormElementEquals(final String formElementName, final String expectedValue) {
849         int assertLevel = AssertLevel.NO_LEVEL;
850         assertFormElementEquals(formElementName, expectedValue, assertLevel);
851     }
852 
853     /***
854      * Assert that a specific form element has an expected value.
855      *
856      * @param formElementName
857      * @param expectedValue
858      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
859      */
860     public void assertFormElementEquals(final String formElementName, final String expectedValue, int assertLevel) {
861         assertMethodWithLevel(new Runnable() {
862                 public void run() {
863                     session.assertFormElementEquals(formElementName,expectedValue);
864                 }
865         }, assertLevel);
866     }
867 
868     /***
869      * Assert that a form element had no value / is empty.
870      *
871      * @param formElementName
872      */
873     public void assertFormElementEmpty(final String formElementName) {
874         int assertLevel = AssertLevel.NO_LEVEL;
875         assertFormElementEmpty(formElementName, assertLevel);
876     }
877 
878     /***
879      * Assert that a form element had no value / is empty.
880      *
881      * @param formElementName
882      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
883      */
884     public void assertFormElementEmpty(final String formElementName, int assertLevel) {
885         assertMethodWithLevel(new Runnable() {
886                 public void run() {
887                     session.assertFormElementEmpty(formElementName);
888                 }
889         }, assertLevel);
890     }
891 
892     /***
893      * Assert that a specific checkbox is selected.
894      *
895      * @param checkBoxName
896      */
897     public void assertCheckboxSelected(final String checkBoxName) {
898         int assertLevel = AssertLevel.NO_LEVEL;
899         assertCheckboxSelected(checkBoxName, assertLevel);
900     }
901 
902     /***
903      * Assert that a specific checkbox is selected.
904      *
905      * @param checkBoxName
906      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
907      */
908     public void assertCheckboxSelected(final String checkBoxName, int assertLevel) {
909         assertMethodWithLevel(new Runnable() {
910                 public void run() {
911                     session.assertCheckboxSelected(checkBoxName);
912                 }
913         }, assertLevel);
914     }
915 
916     /***
917      * Assert that a specific checkbox is not selected.
918      *
919      * @param checkBoxName
920      */
921     public void assertCheckboxNotSelected(final String checkBoxName) {
922         int assertLevel = AssertLevel.NO_LEVEL;
923         assertCheckboxNotSelected(checkBoxName, assertLevel);
924     }
925 
926     /***
927      * Assert that a specific checkbox is not selected.
928      *
929      * @param checkBoxName
930      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
931      */
932     public void assertCheckboxNotSelected(final String checkBoxName, int assertLevel) {
933         assertMethodWithLevel(new Runnable() {
934                 public void run() {
935                     session.assertCheckboxNotSelected(checkBoxName);
936                 }
937         }, assertLevel);
938     }
939 
940     /***
941      * Assert that a specific option is present in a radio group.
942      *
943      * @param name radio group name.
944      * @param radioOption option to test for.
945      */
946     public void assertRadioOptionPresent(final String name, final String radioOption) {
947         int assertLevel = AssertLevel.NO_LEVEL;
948         assertRadioOptionPresent(name, radioOption, assertLevel);
949     }
950 
951     /***
952      * Assert that a specific option is present in a radio group.
953      *
954      * @param name radio group name.
955      * @param radioOption option to test for.
956      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
957      */
958     public void assertRadioOptionPresent(final String name, final String radioOption, int assertLevel) {
959         assertMethodWithLevel(new Runnable() {
960                 public void run() {
961                     session.assertRadioOptionPresent(name,radioOption);
962                 }
963         }, assertLevel);
964     }
965 
966     /***
967      * Assert that a specific option is not present in a radio group.
968      *
969      * @param name radio group name.
970      * @param radioOption option to test for.
971      */
972     public void assertRadioOptionNotPresent(final String name, final String radioOption) {
973         int assertLevel = AssertLevel.NO_LEVEL;
974         assertRadioOptionNotPresent(name, radioOption, assertLevel);
975     }
976 
977     /***
978      * Assert that a specific option is not present in a radio group.
979      *
980      * @param name radio group name.
981      * @param radioOption option to test for.
982      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
983      */
984     public void assertRadioOptionNotPresent(final String name, final String radioOption, int assertLevel) {
985         assertMethodWithLevel(new Runnable() {
986                 public void run() {
987                     session.assertRadioOptionNotPresent(name,radioOption);
988                 }
989         }, assertLevel);
990     }
991 
992     /***
993      * Assert that a specific option is selected in a radio group.
994      *
995      * @param name radio group name.
996      * @param radioOption option to test for selection.
997      */
998     public void assertRadioOptionSelected(final String name, final String radioOption) {
999         int assertLevel = AssertLevel.NO_LEVEL;
1000         assertRadioOptionSelected(name, radioOption, assertLevel);
1001     }
1002 
1003     /***
1004      * Assert that a specific option is selected in a radio group.
1005      *
1006      * @param name radio group name.
1007      * @param radioOption option to test for selection.
1008      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1009      */
1010     public void assertRadioOptionSelected(final String name, final String radioOption, int assertLevel) {
1011         assertMethodWithLevel(new Runnable() {
1012                 public void run() {
1013                     session.assertRadioOptionSelected(name,radioOption);
1014                 }
1015         }, assertLevel);
1016     }
1017 
1018     /***
1019      * Assert that a specific option is not selected in a radio group.
1020      *
1021      * @param name radio group name.
1022      * @param radioOption option to test for selection.
1023      */
1024     public void assertRadioOptionNotSelected(final String name, final String radioOption) {
1025         int assertLevel = AssertLevel.NO_LEVEL;
1026         assertRadioOptionNotSelected(name, radioOption, assertLevel);
1027     }
1028 
1029     /***
1030      * Assert that a specific option is not selected in a radio group.
1031      *
1032      * @param name radio group name.
1033      * @param radioOption option to test for selection.
1034      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1035      */
1036     public void assertRadioOptionNotSelected(final String name, final String radioOption, int assertLevel) {
1037         assertMethodWithLevel(new Runnable() {
1038                 public void run() {
1039                     session.assertRadioOptionNotSelected(name,radioOption);
1040                 }
1041         }, assertLevel);
1042     }
1043 
1044     /***
1045      * Assert that the display values of a select element's options match a given array of strings.
1046      *
1047      * @param selectName name of the select element.
1048      * @param expectedOptions expected display values for the select box.
1049      */
1050     public void assertOptionsEqual(final String selectName, final String[] expectedOptions) {
1051         int assertLevel = AssertLevel.NO_LEVEL;
1052         assertOptionsEqual(selectName, expectedOptions, assertLevel);
1053     }
1054 
1055     /***
1056      * Assert that the display values of a select element's options match a given array of strings.
1057      *
1058      * @param selectName name of the select element.
1059      * @param expectedOptions expected display values for the select box.
1060      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1061      */
1062     public void assertOptionsEqual(final String selectName, final String[] expectedOptions, int assertLevel) {
1063         assertMethodWithLevel(new Runnable() {
1064                 public void run() {
1065                     session.assertOptionsEqual(selectName,expectedOptions);
1066                 }
1067         }, assertLevel);
1068     }
1069 
1070     /***
1071      * Assert that the display values of a select element's options do not match a given array of strings.
1072      *
1073      * @param selectName name of the select element.
1074      * @param expectedOptions expected display values for the select box.
1075      */
1076     public void assertOptionsNotEqual(final String selectName, final String[] expectedOptions) {
1077         int assertLevel = AssertLevel.NO_LEVEL;
1078         assertOptionsNotEqual(selectName, expectedOptions, assertLevel);
1079     }
1080 
1081     /***
1082      * Assert that the display values of a select element's options do not match a given array of strings.
1083      *
1084      * @param selectName name of the select element.
1085      * @param expectedOptions expected display values for the select box.
1086      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1087      */
1088     public void assertOptionsNotEqual(final String selectName, final String[] expectedOptions, int assertLevel) {
1089         assertMethodWithLevel(new Runnable() {
1090                 public void run() {
1091                     session.assertOptionsNotEqual(selectName,expectedOptions);
1092                 }
1093         }, assertLevel);
1094     }
1095 
1096     /***
1097      * Assert that the values of a select element's options match a given array of strings.
1098      *
1099      * @param selectName name of the select element.
1100      * @param expectedValues expected values for the select box.
1101      */
1102     public void assertOptionValuesEqual(final String selectName, final String[] expectedValues) {
1103         int assertLevel = AssertLevel.NO_LEVEL;
1104         assertOptionValuesEqual(selectName, expectedValues, assertLevel);
1105     }
1106 
1107     /***
1108      * Assert that the values of a select element's options match a given array of strings.
1109      *
1110      * @param selectName name of the select element.
1111      * @param expectedValues expected values for the select box.
1112      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1113      */
1114     public void assertOptionValuesEqual(final String selectName, final String[] expectedValues, int assertLevel) {
1115         assertMethodWithLevel(new Runnable() {
1116                 public void run() {
1117                     session.assertOptionValuesEqual(selectName,expectedValues);
1118                 }
1119         }, assertLevel);
1120     }
1121 
1122     /***
1123      * Assert that the values of a select element's options do not match a given array of strings.
1124      *
1125      * @param selectName name of the select element.
1126      * @param optionValues expected values for the select box.
1127      */
1128     public void assertOptionValuesNotEqual(final String selectName, final String[] optionValues) {
1129         int assertLevel = AssertLevel.NO_LEVEL;
1130         assertOptionValuesNotEqual(selectName, optionValues, assertLevel);
1131     }
1132 
1133     /***
1134      * Assert that the values of a select element's options do not match a given array of strings.
1135      *
1136      * @param selectName name of the select element.
1137      * @param optionValues expected values for the select box.
1138      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1139      */
1140     public void assertOptionValuesNotEqual(final String selectName, final String[] optionValues, int assertLevel) {
1141         assertMethodWithLevel(new Runnable() {
1142                 public void run() {
1143                     session.assertOptionValuesNotEqual(selectName,optionValues);
1144                 }
1145         }, assertLevel);
1146     }
1147 
1148     /***
1149      * Assert that the currently selected display value of a select box matches a given value.
1150      *
1151      * @param selectName name of the select element.
1152      * @param option expected display value of the selected option.
1153      */
1154     public void assertOptionEquals(final String selectName, final String option) {
1155         int assertLevel = AssertLevel.NO_LEVEL;
1156         assertOptionEquals(selectName, option, assertLevel);
1157     }
1158 
1159     /***
1160      * Assert that the currently selected display value of a select box matches a given value.
1161      *
1162      * @param selectName name of the select element.
1163      * @param option expected display value of the selected option.
1164      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1165      */
1166     public void assertOptionEquals(final String selectName, final String option, int assertLevel) {
1167         assertMethodWithLevel(new Runnable() {
1168                 public void run() {
1169                     session.assertOptionEquals(selectName,option);
1170                 }
1171         }, assertLevel);
1172     }
1173 
1174     /***
1175      * Assert that a submit button with a given name is present.
1176      *
1177      * @param buttonName
1178      */
1179     public void assertSubmitButtonPresent(final String buttonName) {
1180         int assertLevel = AssertLevel.NO_LEVEL;
1181         assertSubmitButtonPresent(buttonName, assertLevel);
1182     }
1183 
1184     /***
1185      * Assert that a submit button with a given name is present.
1186      *
1187      * @param buttonName
1188      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1189      */
1190     public void assertSubmitButtonPresent(final String buttonName, int assertLevel) {
1191         assertMethodWithLevel(new Runnable() {
1192                 public void run() {
1193                     session.assertSubmitButtonPresent(buttonName);
1194                 }
1195         }, assertLevel);
1196     }
1197 
1198     /***
1199      * Assert that a submit button with a given name is not present.
1200      *
1201      * @param buttonName
1202      */
1203     public void assertSubmitButtonNotPresent(final String buttonName) {
1204         int assertLevel = AssertLevel.NO_LEVEL;
1205         assertSubmitButtonNotPresent(buttonName, assertLevel);
1206     }
1207 
1208     /***
1209      * Assert that a submit button with a given name is not present.
1210      *
1211      * @param buttonName
1212      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1213      */
1214     public void assertSubmitButtonNotPresent(final String buttonName, int assertLevel) {
1215         assertMethodWithLevel(new Runnable() {
1216                 public void run() {
1217                     session.assertSubmitButtonNotPresent(buttonName);
1218                 }
1219         }, assertLevel);
1220     }
1221 
1222     /***
1223      * Assert that a submit button with a given name and value is present.
1224      *
1225      * @param buttonName
1226      * @param expectedValue
1227      */
1228     public void assertSubmitButtonValue(final String buttonName, final String expectedValue) {
1229         int assertLevel = AssertLevel.NO_LEVEL;
1230         assertSubmitButtonValue(buttonName, expectedValue, assertLevel);
1231     }
1232 
1233     /***
1234      * Assert that a submit button with a given name and value is present.
1235      *
1236      * @param buttonName
1237      * @param expectedValue
1238      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1239      */
1240     public void assertSubmitButtonValue(final String buttonName, final String expectedValue, int assertLevel) {
1241         assertMethodWithLevel(new Runnable() {
1242                 public void run() {
1243                     session.assertSubmitButtonValue(buttonName,expectedValue);
1244                 }
1245         }, assertLevel);
1246     }
1247 
1248     /***
1249      * Assert that a button with a given id is present.
1250      *
1251      * @param buttonId
1252      */
1253     public void assertButtonPresent(final String buttonId) {
1254         int assertLevel = AssertLevel.NO_LEVEL;
1255         assertButtonPresent(buttonId, assertLevel);
1256     }
1257 
1258     /***
1259      * Assert that a button with a given id is present.
1260      *
1261      * @param buttonId
1262      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1263      */
1264     public void assertButtonPresent(final String buttonId, int assertLevel) {
1265         assertMethodWithLevel(new Runnable() {
1266                 public void run() {
1267                     session.assertButtonPresent(buttonId);
1268                 }
1269         }, assertLevel);
1270     }
1271 
1272     /***
1273      * Assert that a button with a given id is not present.
1274      *
1275      * @param buttonId
1276      */
1277     public void assertButtonNotPresent(final String buttonId) {
1278         int assertLevel = AssertLevel.NO_LEVEL;
1279         assertButtonNotPresent(buttonId, assertLevel);
1280     }
1281 
1282     /***
1283      * Assert that a button with a given id is not present.
1284      *
1285      * @param buttonId
1286      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1287      */
1288     public void assertButtonNotPresent(final String buttonId, int assertLevel) {
1289         assertMethodWithLevel(new Runnable() {
1290                 public void run() {
1291                     session.assertButtonNotPresent(buttonId);
1292                 }
1293         }, assertLevel);
1294     }
1295 
1296 
1297     /***
1298      * Assert that a link with a given id is present in the response.
1299      *
1300      * @param linkId
1301      */
1302     public void assertLinkPresent(final String linkId) {
1303         int assertLevel = AssertLevel.NO_LEVEL;
1304         assertLinkPresent(linkId, assertLevel);
1305     }
1306 
1307     /***
1308      * Assert that a link with a given id is present in the response.
1309      *
1310      * @param linkId
1311      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1312      */
1313     public void assertLinkPresent(final String linkId, int assertLevel) {
1314         assertMethodWithLevel(new Runnable() {
1315                 public void run() {
1316                     session.assertLinkPresent(linkId);
1317                 }
1318         }, assertLevel);
1319     }
1320 
1321     /***
1322      * Assert that no link with the given id is present in the response.
1323      *
1324      * @param linkId
1325      */
1326     public void assertLinkNotPresent(final String linkId) {
1327         int assertLevel = AssertLevel.NO_LEVEL;
1328         assertLinkNotPresent(linkId, assertLevel);
1329     }
1330 
1331     /***
1332      * Assert that no link with the given id is present in the response.
1333      *
1334      * @param linkId
1335      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1336      */
1337     public void assertLinkNotPresent(final String linkId, int assertLevel) {
1338         assertMethodWithLevel(new Runnable() {
1339                 public void run() {
1340                     session.assertLinkNotPresent(linkId);
1341                 }
1342         }, assertLevel);
1343     }
1344 
1345     /***
1346      * Assert that a link containing the supplied text is present.
1347      *
1348      * @param linkText
1349      */
1350     public void assertLinkPresentWithText(final String linkText) {
1351         int assertLevel = AssertLevel.NO_LEVEL;
1352         assertLinkPresentWithText(linkText, assertLevel);
1353     }
1354 
1355     /***
1356      * Assert that a link containing the supplied text is present.
1357      *
1358      * @param linkText
1359      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1360      */
1361     public void assertLinkPresentWithText(final String linkText, int assertLevel) {
1362         assertMethodWithLevel(new Runnable() {
1363                 public void run() {
1364                     session.assertLinkPresentWithText(linkText);
1365                 }
1366         }, assertLevel);
1367     }
1368 
1369     /***
1370      * Assert that no link containing the supplied text is present.
1371      *
1372      * @param linkText
1373      */
1374     public void assertLinkNotPresentWithText(final String linkText) {
1375         int assertLevel = AssertLevel.NO_LEVEL;
1376         assertLinkNotPresentWithText(linkText, assertLevel);
1377     }
1378 
1379     /***
1380      * Assert that no link containing the supplied text is present.
1381      *
1382      * @param linkText
1383      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1384      */
1385     public void assertLinkNotPresentWithText(final String linkText, int assertLevel) {
1386         assertMethodWithLevel(new Runnable() {
1387                 public void run() {
1388                     session.assertLinkNotPresentWithText(linkText);
1389                 }
1390         }, assertLevel);
1391     }
1392 
1393     /***
1394      * Assert that a link containing a specified image is present.
1395      *
1396      * @param imageFileName A suffix of the image's filename; for example, to match
1397      *                      <tt>"images/my_icon.png"</tt>, you could just pass in
1398      *                      <tt>"my_icon.png"</tt>.
1399      */
1400     public void assertLinkPresentWithImage(final String imageFileName) {
1401         int assertLevel = AssertLevel.NO_LEVEL;
1402         assertLinkPresentWithImage(imageFileName, assertLevel);
1403     }
1404 
1405     /***
1406      * Assert that a link containing a specified image is present.
1407      *
1408      * @param imageFileName A suffix of the image's filename; for example, to match
1409      *                      <tt>"images/my_icon.png"</tt>, you could just pass in
1410      *                      <tt>"my_icon.png"</tt>.
1411      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1412      */
1413     public void assertLinkPresentWithImage(final String imageFileName, int assertLevel) {
1414         assertMethodWithLevel(new Runnable() {
1415                 public void run() {
1416                     session.assertLinkPresentWithImage(imageFileName);
1417                 }
1418         }, assertLevel);
1419     }
1420 
1421     /***
1422      * Assert that a link containing a specified image is not present.
1423      *
1424      * @param imageFileName A suffix of the image's filename; for example, to match
1425      *                      <tt>"images/my_icon.png"</tt>, you could just pass in
1426      *                      <tt>"my_icon.png"</tt>.
1427      */
1428     public void assertLinkNotPresentWithImage(final String imageFileName) {
1429         int assertLevel = AssertLevel.NO_LEVEL;
1430         assertLinkNotPresentWithImage(imageFileName, assertLevel);
1431     }
1432 
1433     /***
1434      * Assert that a link containing a specified image is not present.
1435      *
1436      * @param imageFileName A suffix of the image's filename; for example, to match
1437      *                      <tt>"images/my_icon.png"</tt>, you could just pass in
1438      *                      <tt>"my_icon.png"</tt>.
1439      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1440      */
1441     public void assertLinkNotPresentWithImage(final String imageFileName, int assertLevel) {
1442         assertMethodWithLevel(new Runnable() {
1443                 public void run() {
1444                     session.assertLinkNotPresentWithImage(imageFileName);
1445                 }
1446         }, assertLevel);
1447     }
1448 
1449     /***
1450      * Assert that an element with a given id is present.
1451      *
1452      * @param anID element id to test for.
1453      */
1454     public void assertElementPresent(final String anID) {
1455         int assertLevel = AssertLevel.NO_LEVEL;
1456         assertElementPresent(anID, assertLevel);
1457     }
1458 
1459     /***
1460      * Assert that an element with a given id is present.
1461      *
1462      * @param anID element id to test for.
1463      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1464      */
1465     public void assertElementPresent(final String anID, int assertLevel) {
1466         assertMethodWithLevel(new Runnable() {
1467                 public void run() {
1468                     session.assertElementPresent(anID);
1469                 }
1470         }, assertLevel);
1471     }
1472 
1473     /***
1474      * Assert that an element with a given id is not present.
1475      *
1476      * @param anID element id to test for.
1477      */
1478     public void assertElementNotPresent(final String anID) {
1479         int assertLevel = AssertLevel.NO_LEVEL;
1480         assertElementNotPresent(anID, assertLevel);
1481     }
1482 
1483     /***
1484      * Assert that an element with a given id is not present.
1485      *
1486      * @param anID element id to test for.
1487      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1488      */
1489     public void assertElementNotPresent(final String anID, int assertLevel) {
1490         assertMethodWithLevel(new Runnable() {
1491                 public void run() {
1492                     session.assertElementNotPresent(anID);
1493                 }
1494         }, assertLevel);
1495     }
1496 
1497     /***
1498      * Assert that a given element contains specific text.
1499      *
1500      * @param elementID id of element to be inspected.
1501      * @param text to check for.
1502      */
1503     public void assertTextInElement(final String elementID, final String text) {
1504         int assertLevel = AssertLevel.NO_LEVEL;
1505         assertTextInElement(elementID, text, assertLevel);
1506     }
1507 
1508     /***
1509      * Assert that a given element contains specific text.
1510      *
1511      * @param elementID id of element to be inspected.
1512      * @param text to check for.
1513      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1514      */
1515     public void assertTextInElement(final String elementID, final String text, int assertLevel) {
1516         assertMethodWithLevel(new Runnable() {
1517                 public void run() {
1518                     session.assertTextInElement(elementID,text);
1519                 }
1520         }, assertLevel);
1521     }
1522 
1523     /***
1524      * Assert that a window with the given name is open.
1525      *
1526      * @param windowName
1527      */
1528     public void assertWindowPresent(final String windowName) {
1529         int assertLevel = AssertLevel.NO_LEVEL;
1530         assertWindowPresent(windowName, assertLevel);
1531     }
1532 
1533     /***
1534      * Assert that a window with the given name is open.
1535      *
1536      * @param windowName
1537      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1538      */
1539     public void assertWindowPresent(final String windowName, int assertLevel) {
1540         assertMethodWithLevel(new Runnable() {
1541                 public void run() {
1542                     session.assertWindowPresent(windowName);
1543                 }
1544         }, assertLevel);
1545     }
1546 
1547     /***
1548      * Assert that a frame with the given name is present.
1549      *
1550      * @param frameName
1551      */
1552     public void assertFramePresent(final String frameName) {
1553         int assertLevel = AssertLevel.NO_LEVEL;
1554         assertFramePresent(frameName, assertLevel);
1555     }
1556 
1557     /***
1558      * Assert that a frame with the given name is present.
1559      *
1560      * @param frameName
1561      * @param assertLevel - Only run this test under the assertLevel as described in {@link net.sf.jameleon.util.AssertLevel}
1562      */
1563     public void assertFramePresent(final String frameName, int assertLevel) {
1564         assertMethodWithLevel(new Runnable() {
1565                 public void run() {
1566                     session.assertFramePresent(frameName);
1567                 }
1568         }, assertLevel);
1569     }
1570 
1571 //Form interaction methods
1572 
1573     /***
1574      * Begin interaction with a specified form.  If form interaction methods are called without
1575      * explicitly calling this method first, jWebUnit will attempt to determine itself which form
1576      * is being manipulated.
1577      *
1578      * It is not necessary to call this method if their is only one form on the current page.
1579      *
1580      * @param nameOrId name or id of the form to work with.
1581      */
1582     public void setWorkingForm(String nameOrId) {
1583         session.setWorkingForm(nameOrId);
1584     }
1585 
1586     /***
1587      * Set the value of a form input element.
1588      *
1589      * @param formElementName name of form element.
1590      * @param value
1591      */
1592     public void setFormElement(String formElementName, String value) {
1593         session.setFormElement(formElementName,value);
1594     }
1595 
1596     /***
1597      * Select a specified checkbox.
1598      *
1599      * @param checkBoxName name of checkbox to be deselected.
1600      */
1601     public void checkCheckbox(String checkBoxName) {
1602         session.checkCheckbox(checkBoxName);
1603     }
1604 
1605     /***
1606      * Deselect a specified checkbox.
1607      *
1608      * @param checkBoxName name of checkbox to be deselected.
1609      */
1610     public void uncheckCheckbox(String checkBoxName) {
1611         session.uncheckCheckbox(checkBoxName);
1612     }
1613 
1614     /***
1615      * Select an option with a given display value in a select element.
1616      *
1617      * @param selectName name of select element.
1618      * @param option display value of option to be selected.
1619      */
1620     public void selectOption(String selectName, String option) {
1621         session.selectOption(selectName,option);
1622     }
1623 
1624     //Form submission and link navigation methods
1625 
1626     /***
1627      * Submit form - default submit button will be used (unnamed submit button, or
1628      * named button if there is only one on the form.
1629      */
1630     public void submit() {
1631         recordHttpResultBlock(new Runnable(){
1632                 public void run() {
1633                     session.submit();
1634                 }
1635         });
1636     }
1637 
1638     /***
1639      * Submit form by pressing named button.
1640      *
1641      * @param buttonName name of button to submit form with.
1642      */
1643     public void submit(final String buttonName) {
1644         recordHttpResultBlock(new Runnable(){
1645                 public void run() {
1646                     session.submit(buttonName);
1647                 }
1648         });
1649     }
1650 
1651     /***
1652      * Reset the current form.
1653      */
1654     public void reset() {
1655         session.reset();
1656     }
1657 
1658     /***
1659      * Navigate by selection of a link containing given text.
1660      *
1661      * @param linkText
1662      */
1663     public void clickLinkWithText(final String linkText) {
1664         recordHttpResultBlock(new Runnable(){
1665                 public void run() {
1666                     session.clickLinkWithText(linkText);
1667                 }
1668         });
1669     }
1670 
1671     /***
1672      * Click the button with the given id.
1673      *
1674      * @param buttonId
1675      */
1676     public void clickButton(final String buttonId) {
1677         recordHttpResultBlock(new Runnable(){
1678                 public void run() {
1679                     session.clickButton(buttonId);
1680                 }
1681         });
1682     }
1683 
1684     /***
1685      * Navigate by selection of a link with a given image.
1686      *
1687      * @param imageFileName A suffix of the image's filename; for example, to match
1688      *                      <tt>"images/my_icon.png"</tt>, you could just pass in
1689      *                      <tt>"my_icon.png"</tt>.
1690      */
1691     public void clickLinkWithImage(final String imageFileName) {
1692         recordHttpResultBlock(new Runnable(){
1693                 public void run() {
1694                     session.clickLinkWithImage(imageFileName);
1695                 }
1696         });
1697     }
1698 
1699 
1700     /***
1701      * Navigate by selection of a link with given id.
1702      *
1703      * @param linkId id of link
1704      */
1705     public void clickLink(final String linkId) {
1706         recordHttpResultBlock(new Runnable(){
1707                 public void run() {
1708                     session.clickLink(linkId);
1709                 }
1710         });
1711     }
1712 
1713     //Window and Frame Navigation Methods
1714 
1715     /***
1716      * Make a given window active (current response will be window's contents).
1717      *
1718      * @param windowName
1719      */
1720     public void gotoWindow(String windowName) {
1721         session.gotoWindow(windowName);
1722     }
1723                
1724     /***
1725      * Make the root window active.
1726      */
1727     public void gotoRootWindow() {
1728         session.gotoRootWindow();
1729     }
1730 
1731     /***
1732      * Make the named frame active (current response will be frame's contents).
1733      *
1734      * @param frameName
1735      */
1736     public void gotoFrame(String frameName) {
1737         session.gotoFrame(frameName);
1738     }
1739 
1740 //Debug methods
1741 
1742     /***
1743      * Dump html of current response to a specified stream - for debugging purposes.
1744      *
1745      * @param stream
1746      */
1747     public void dumpResponse(PrintStream stream) {
1748         session.dumpResponse(stream);
1749     }
1750 
1751     /***
1752      * Dump the table as the 2D array that is used for assertions - for debugging purposes.
1753      *
1754      * @param tableNameOrId
1755      * @param stream
1756      */
1757     public void dumpTable(String tableNameOrId, PrintStream stream) {
1758         session.dumpTable(tableNameOrId,stream);
1759     }
1760 
1761     /***
1762      * Dump the table as the 2D array that is used for assertions - for debugging purposes.
1763      *
1764      * @param tableNameOrId
1765      * @param table
1766      */
1767     public void dumpTable(String tableNameOrId, String[][] table) {
1768         session.dumpTable(tableNameOrId,table);
1769     }
1770 
1771     /***
1772      * Dump the table as the 2D array that is used for assertions - for debugging purposes.
1773      *
1774      * @param tableNameOrId
1775      * @param table
1776      * @param stream
1777      */
1778     public void dumpTable(String tableNameOrId, String[][] table, PrintStream stream) {
1779         session.dumpTable(tableNameOrId,table,stream);
1780     }
1781 }