View Javadoc

1   /**
2    * Copyright (c) 2002-2015, JWebUnit team.
3    *
4    * This file is part of JWebUnit.
5    *
6    * JWebUnit is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU Lesser General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * JWebUnit is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU Lesser General Public License
17   * along with JWebUnit.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  package net.sourceforge.jwebunit.api;
20  
21  import java.util.Map;
22  
23  import java.io.InputStream;
24  import java.net.URL;
25  import java.util.List;
26  
27  import net.sourceforge.jwebunit.exception.ExpectedJavascriptAlertException;
28  import net.sourceforge.jwebunit.exception.ExpectedJavascriptConfirmException;
29  import net.sourceforge.jwebunit.exception.ExpectedJavascriptPromptException;
30  import net.sourceforge.jwebunit.exception.TestingEngineResponseException;
31  import net.sourceforge.jwebunit.html.Table;
32  import net.sourceforge.jwebunit.javascript.JavascriptAlert;
33  import net.sourceforge.jwebunit.javascript.JavascriptConfirm;
34  import net.sourceforge.jwebunit.javascript.JavascriptPrompt;
35  import net.sourceforge.jwebunit.util.TestContext;
36  import net.sourceforge.jwebunit.api.IElement;
37  
38  /**
39   * This is the interface for all communications between JWebUnit and the specific running test engine.
40   *
41   * @author Julien Henry
42   * @author Nick Neuberger
43   */
44  public interface ITestingEngine {
45  
46      /**
47       * Open the browser at an initial URL.
48       *
49       * @param aInitialURL Initial URL
50       * @param aTestContext Test context
51       * @throws TestingEngineResponseException If something bad happend (404)
52       */
53      void beginAt(URL aInitialURL, TestContext aTestContext)
54              throws TestingEngineResponseException;
55  
56      /**
57       * Close the browser and check if there is no pending Javascript alert, confirm or prompt.
58       *
59       * @throws ExpectedJavascriptAlertException If there is pending Javascript alert
60       *             {@link ITestingEngine#setExpectedJavaScriptAlert(JavascriptAlert[])}
61       * @throws ExpectedJavascriptConfirmException If there is pending Javascript confirm
62       *             {@link ITestingEngine#setExpectedJavaScriptConfirm(JavascriptConfirm[])}
63       * @throws ExpectedJavascriptPromptException If there is pending Javascript prompt
64       *             {@link ITestingEngine#setExpectedJavaScriptPrompt(JavascriptPrompt[])}
65       */
66      void closeBrowser() throws ExpectedJavascriptAlertException,
67              ExpectedJavascriptConfirmException,
68              ExpectedJavascriptPromptException;
69  
70      /**
71       * Simulate user typing a new URL in the browser.
72       *
73       * @param url Full URL of the page.
74       * @throws TestingEngineResponseException If something bad happend (404)
75       */
76      void gotoPage(URL url) throws TestingEngineResponseException;
77  
78      /**
79       * Enable or disable Javascript support.
80       *
81       * @param value true to enable Javascript.
82       */
83      void setScriptingEnabled(boolean value);
84  
85      /**
86       * Set whether or not to throw an exception on Javascript errors.
87       *
88       * @param value true to throw an exception on Javascript errors.
89       */
90      void setThrowExceptionOnScriptError(boolean value);
91  
92      /**
93       * Get all cookies.
94       *
95       * @return List of javax.servlet.http.Cookie.
96       */
97      List<?> getCookies();
98  
99      /**
100      * Test if the window with the given name is present.
101      *
102      * @param windowName Name of the window.
103      * @return true if the Window exists.
104      */
105     boolean hasWindow(String windowName);
106 
107     /**
108      * Test if window with the given title is present.
109      *
110      * @param windowTitle Title of the window.
111      * @return true if the Window exists.
112      */
113     boolean hasWindowByTitle(String windowTitle);
114 
115     /**
116      * Make the window with the given name active.
117      *
118      * @param windowName Name of the window
119      */
120     void gotoWindow(String windowName);
121 
122     /**
123      * Goto first window with the given title.
124      *
125      * @param title Title of the window
126      */
127     void gotoWindowByTitle(String title);
128 
129     /**
130      * Goto window with the given Javascript ID.
131      *
132      * @param windowID Javascript ID of the window
133      * @deprecated Javascript ID does'nt not exists. Currently this is an index
134      * in the list of available windows, but this is not portable (and probably not stable).
135      * Use {@link #gotoWindow(String)} or {@link #gotoWindowByTitle(String)} instead.
136      */
137     @Deprecated
138     void gotoWindow(int windowID);
139 
140     /**
141      * Make the root window active. Used to reset the effect of {@link ITestingEngine#gotoFrame(String)}.
142      *
143      */
144     void gotoRootWindow();
145 
146     /**
147      * Get the number of opened Windows.
148      *
149      * @return Number of opened Windows.
150      */
151     int getWindowCount();
152 
153     /**
154      * Close the current window.
155      *
156      */
157     void closeWindow();
158 
159     /**
160      * Test if the given frame is present.
161      *
162      * @param frameNameOrId Name or ID of the frame. ID is checked first.
163      * @return true if the frame exists.
164      */
165     boolean hasFrame(String frameNameOrId);
166 
167     /**
168      * Make the frame with the given name or ID active in the current conversation.
169      *
170      * @param frameNameOrId Name or ID of the frame. ID is checked first.
171      */
172     void gotoFrame(String frameNameOrId);
173 
174     /**
175      * Set the form on the current page that the client wishes to work with explicitly by index in the page.
176      *
177      * @param index The 0-based index, when more than one form with the same name is expected.
178      */
179     void setWorkingForm(int index);
180 
181     /**
182      * Set the form on the current page that the client wishes to work with explicitly by either the form name or id
183      * (match by id is attempted first).
184      *
185      * @param nameOrId name or id of the form to be worked with.
186      * @param index The 0-based index, when more than one form with the same name is expected.
187      */
188     void setWorkingForm(String nameOrId, int index);
189 
190     /**
191      * Check whether the current page contains a form.
192      *
193      * @return true if there is at least a form.
194      */
195     boolean hasForm();
196 
197     /**
198      * Return true if the current page contains a specific form.
199      *
200      * @param nameOrID name of id of the form to check for.
201      * @return true if there is at least a form.
202      */
203     boolean hasForm(String nameOrID);
204 
205     /**
206      * Return true if the current page contains a specific form.
207      *
208      * @param nameOrID name of id of the form to check for.
209      * @param index The 0-based index, when more than one form with the same name is expected.
210      * @return true if there is at least a form.
211      */
212     boolean hasForm(String nameOrID, int index);
213 
214     /**
215      * Return true if a form input element is present on the current form.
216      *
217      * @param paramName name of the input element to check for
218      * @return true if there is at least a form parameter.
219      */
220     boolean hasFormParameterNamed(String paramName);
221 
222     /**
223      * Return the current value of a text field with name <code>paramName</code>. Text fields are input text, input
224      * password and textarea
225      *
226      * @param paramName name of the text field element.
227      * @return Text content of the text field.
228      */
229     String getTextFieldValue(String paramName);
230 
231     /**
232      * Return the current value of a hidden input element with name <code>paramName</code>.
233      *
234      * @param paramName name of the hidden input element.
235      * @return Value of the hidden input.
236      */
237     String getHiddenFieldValue(String paramName);
238 
239     /**
240      * Fill a text, password or textarea field with the provided text.
241      *
242      * @param inputName name of the text, password or textarea element
243      * @param text value to type in the field.
244      */
245     void setTextField(String inputName, String text);
246 
247     /**
248      * Fill hidden field with the provided text.
249      *
250      * @param inputName name of the hidden element
251      * @param text value to set in the hidden field.
252      */
253     void setHiddenField(String inputName, String text);
254 
255     /**
256      * Return a string array of select box option values.
257      *
258      * Exemple: <br/>
259      *
260      * <code>
261      *     <FORM action="http://my_host/doit" method="post">
262      *         <P>
263      *             <SELECT multiple size="4" name="component-select">
264      *                 <OPTION selected value="Component_1_a">Component_1</OPTION>
265      *                 <OPTION selected value="Component_1_b">Component_2</OPTION>
266      *                 <OPTION>Component_3</OPTION>
267      *                 <OPTION>Component_4</OPTION>
268      *                 <OPTION>Component_5</OPTION>
269      *              </SELECT><BR/>
270      *              <INPUT type="submit" value="Send">
271      *              <INPUT type="reset">
272      *         </P>
273      *     </FORM>
274      * </code>
275      *
276      * Should return [Component_1_a, Component_1_b, Component_3, Component_4, Component_5]
277      *
278      * @param selectName name of the select box.
279      * @return Array of select options values.
280      */
281     String[] getSelectOptionValues(String selectName);
282 
283     /**
284      * Return a string array of option values for the Nth select box
285      * with the specified name.
286      *
287      * @param selectName name of the select box.
288      * @param index the 0-based index used when more than one select with
289      * the same name is expected.
290      * @return Array of select options values.
291      */
292     String[] getSelectOptionValues(String selectName, int index);
293 
294     /**
295      * Return the values of the currently selected items in a select box.
296      *
297      * @param selectName name of the select box.
298      */
299     String[] getSelectedOptions(String selectName);
300 
301     /**
302      * Return the values of the currently selected items in the Nth select box
303      * with the provided name.
304      *
305      * @param selectName name of the select box.
306      * @param index the 0-based index used when more than one select with
307      * the same name is expected.
308      */
309     String[] getSelectedOptions(String selectName, int index);
310 
311 
312     /**
313      * Get the label for a given option of a select box.
314      *
315      * @param selectName name of the select box.
316      * @param optionValue label of the option.
317      */
318     String getSelectOptionLabelForValue(String selectName, String optionValue);
319 
320     /**
321      * Get the label for a given option of the Nth select box with the
322      * specified name.
323      *
324      * @param selectName name of the select box.
325      * @param index the 0-based index used when more than one select with
326      * the same name is expected.
327      * @param optionValue label of the option.
328      */
329     String getSelectOptionLabelForValue(String selectName, int index, String optionValue);
330 
331 
332     /**
333      * Get the value for a given option of a select box.
334      *
335      * @param selectName name of the select box.
336      * @param optionLabel label of the option.
337      */
338     String getSelectOptionValueForLabel(String selectName, String optionLabel);
339 
340     /**
341      * Get the value for a given option of the Nth select box with
342      * the specified name.
343      *
344      * @param selectName name of the select box.
345      * @param index the 0-based index used when more than one select with
346      * the same name is expected.
347      * @param optionLabel label of the option.
348      */
349     String getSelectOptionValueForLabel(String selectName, int index, String optionLabel);
350 
351 
352     /**
353      * Select option(s) of a select box by value.
354      *
355      * @param selectName name of the select box.
356      * @param optionValues values of the options to select.
357      */
358     void selectOptions(String selectName, String[] optionValues);
359 
360     /**
361      * Select option(s) of the Nth select box by value.
362      *
363      * @param selectName name of the select box.
364      * @param index the 0-based index of the select element when multiple
365      * select elements are expected.
366      * @param optionValues values of the options to select.
367      */
368     void selectOptions(String selectName, int index, String[] optionValues);
369 
370 
371     /**
372      * Unselect option(s) of a select box by value.
373      *
374      * @param selectName name of the select box.
375      * @param optionValues vaules of the options to unselect.
376      */
377     void unselectOptions(String selectName, String[] optionValues);
378 
379     /**
380      * Unselect option(s) of the Nth select box with the specified name
381      * by value.
382      *
383      * @param selectName name of the select box.
384      * @param index the 0-based index of the select element when multiple
385      * select elements are expected.
386      * @param optionValues vaules of the options to unselect.
387      */
388     void unselectOptions(String selectName, int index, String[] optionValues);
389 
390 
391     /**
392      * Test if a select box has the given option (by label).
393      *
394      * @param selectName name of the select box.
395      * @param optionLabel label of the option.
396      * @return true if a select box has the given option (by label).
397      */
398     boolean hasSelectOption(String selectName, String optionLabel);
399 
400     /**
401      * Test if a select box has the given option (by value).
402      *
403      * @param selectName name of the select box.
404      * @param optionValue value of the option.
405      * @return true if a select box has the given option (by value).
406      */
407     boolean hasSelectOptionValue(String selectName, String optionValue);
408 
409     /**
410      * Test if the Nth select box has the given option (by label).
411      *
412      * @param selectName name of the select box.
413      * @param index the 0-based index of the select element when multiple
414      * select elements are expected.
415      * @param optionLabel label of the option.
416      * @return true if a select box has the given option (by label).
417      */
418     boolean hasSelectOption(String selectName, int index, String optionLabel);
419 
420     /**
421      * Test if the Nth select box has the given option (by value).
422      *
423      * @param selectName name of the select box.
424      * @param index the 0-based index of the select element when multiple
425      * select elements are expected.
426      * @param optionValue value of the option.
427      * @return true if a select box has the given option (by value).
428      */
429     boolean hasSelectOptionValue(String selectName, int index, String optionValue);
430 
431 
432     /**
433      * Determines if the checkbox is selected.
434      *
435      * @param checkBoxName name of the checkbox.
436      * @return true if the first checkbox with given name is selected.
437      */
438     boolean isCheckboxSelected(String checkBoxName);
439 
440     /**
441      * Determines if the checkbox is selected.
442      *
443      * @param checkBoxName name attribut of the checkbox.
444      * @param checkBoxValue value attribut of the checkbox.
445      * @return true if the first checkbox with given name and value is selected.
446      */
447     boolean isCheckboxSelected(String checkBoxName, String checkBoxValue);
448 
449     /**
450      * Select a specified checkbox. If the checkbox is already checked then the checkbox will stay checked.
451      *
452      * @param checkBoxName name of checkbox to be selected.
453      */
454     void checkCheckbox(String checkBoxName);
455 
456     /**
457      * Select a specified checkbox. If the checkbox is already checked then the checkbox will stay checked.
458      *
459      * @param checkBoxName name of checkbox to be selected.
460      * @param checkBoxValue value of the checkbox (to differenciate checkboxes with the same name).
461      */
462     void checkCheckbox(String checkBoxName, String checkBoxValue);
463 
464     /**
465      * Deselect a specified checkbox. If the checkbox is already unchecked then the checkbox will stay unchecked.
466      *
467      * @param checkBoxName name of checkbox to be deselected.
468      */
469     void uncheckCheckbox(String checkBoxName);
470 
471     /**
472      * Deselect a specified checkbox. If the checkbox is already unchecked then the checkbox will stay unchecked.
473      *
474      * @param checkBoxName name of checkbox to be deselected.
475      * @param value value of the checkbox (to differenciate checkboxes with the same name).
476      */
477     void uncheckCheckbox(String checkBoxName, String value);
478 
479     /**
480      * Clicks a radio option. Asserts that the radio option exists first.
481      *
482      * @param radioGroup name of the radio group.
483      * @param radioOptionValue value of the option to check for.
484      */
485     void clickRadioOption(String radioGroup, String radioOptionValue);
486 
487     /**
488      * Checks if a radio group contains the indicated option.
489      *
490      * @param radioGroup name of the radio group.
491      * @param radioOptionValue value of the option to check for.
492      */
493     boolean hasRadioOption(String radioGroup, String radioOptionValue);
494 
495     /**
496      * Return the currently selected radio button.
497      * @param radioGroup name of the radio group.
498      * @return value of the selected radio.
499      */
500     String getSelectedRadio(String radioGroup);
501 
502     /**
503      * Checks if the current form contains a submit button.
504      *
505      */
506     boolean hasSubmitButton();
507 
508     /**
509      * Checks if the current form contains a specific submit button.<br/> A submit button can be the following HTML
510      * elements:
511      * <ul>
512      * <li>input type=submit
513      * <li>input type=image
514      * <li>button type=submit
515      * </ul>
516      *
517      * @param nameOrID name or id of the button to check for.
518      */
519     boolean hasSubmitButton(String nameOrID);
520 
521     /**
522      * Checks if the current form contains a specific submit button.<br/> A submit button can be the following HTML
523      * elements:
524      * <ul>
525      * <li>input type=submit
526      * <li>input type=image
527      * <li>button type=submit
528      * </ul>
529      *
530      * @param nameOrID name of id of the button to check for.
531      * @param value value of the button
532      */
533     boolean hasSubmitButton(String nameOrID, String value);
534 
535     /**
536      * Submit the current form with the default submit button. See {@link #getForm}for an explanation of how the
537      * current form is established.<br/> A submit button can be the following HTML elements:
538      * <ul>
539      * <li>input type=submit
540      * <li>input type=image
541      * <li>button type=submit
542      * </ul>
543      */
544     void submit();
545 
546     /**
547      * Submit the current form with the specifed submit button. See {@link #getForm}for an explanation of how the
548      * current form is established.<br/> A submit button can be the following HTML elements:
549      * <ul>
550      * <li>input type=submit
551      * <li>input type=image
552      * <li>button type=submit
553      * </ul>
554      *
555      * @param buttonName name of the button to use for submission.
556      */
557     void submit(String buttonName);
558 
559     /**
560      * Submit the current form with the specifed submit button (by name and value). See {@link #getForm}for an
561      * explanation of how the current form is established.<br/> A submit button can be the following HTML elements:
562      * <ul>
563      * <li>input type=submit
564      * <li>input type=image
565      * <li>button type=submit
566      * </ul>
567      *
568      * @author Dragos Manolescu
569      * @param buttonName name of the button to use for submission.
570      * @param buttonValue value/label of the button to use for submission
571      */
572     void submit(String buttonName, String buttonValue);
573 
574     /**
575      * Checks if the current form contains a reset button.<br/> A reset button can be the following HTML elements:
576      * <ul>
577      * <li>input type=reset
578      * <li>button type=reset
579      * </ul>
580      *
581      */
582     boolean hasResetButton();
583 
584     /**
585      * Checks if the current form contains a specific reset button.<br/> A reset button can be the following HTML
586      * elements:
587      * <ul>
588      * <li>input type=reset
589      * <li>button type=reset
590      * </ul>
591      *
592      * @param nameOrID name or id of the button to check for.
593      */
594     boolean hasResetButton(String nameOrID);
595 
596     /**
597      * Reset the current form with the default reset button. See {@link #getForm}for an explanation of how the current
598      * form is established.<br/> A reset button can be the following HTML elements:
599      * <ul>
600      * <li>input type=reset
601      * <li>button type=reset
602      * </ul>
603      */
604     void reset();
605 
606     /**
607      * Checks if a button with <code>text</code> is present.<br/> A button can be the following HTML elements:
608      * <ul>
609      * <li>input type=button
610      * <li>button type=button
611      * </ul>
612      *
613      * @param text the text of the button (contents of the value attribute).
614      * @return <code>true</code> when the button with text could be found.
615      */
616     boolean hasButtonWithText(String text);
617 
618     /**
619      * Checks if a button with <code>id</code> is present.<br/> A button can be the following HTML elements:
620      * <ul>
621      * <li>input type=button
622      * <li>button type=button
623      * </ul>
624      *
625      * @param buttonId the ID of the button.
626      * @return <code>true</code> when the button with text could be found.
627      */
628     boolean hasButton(String buttonId);
629 
630     /**
631      * Click the indicated button. <br/> A button can be the following HTML elements:
632      * <ul>
633      * <li>input type=button
634      * <li>button type=button
635      * </ul>
636      *
637      * @param buttonId the ID of the button.
638      */
639     void clickButton(String buttonId);
640 
641     /**
642      * Clicks a button with <code>text</code> of the value attribute. <br/> A button can be the following HTML
643      * elements:
644      * <ul>
645      * <li>input type=button
646      * <li>button type=button
647      * </ul>
648      *
649      * @param buttonValueText the text of the button (contents of the value attribute).
650      */
651     void clickButtonWithText(String buttonValueText);
652 
653     /**
654      * Get the location of the current page.
655      * @return an URL.
656      */
657     URL getPageURL();
658 
659     /**
660      * Return the string representation of the current page, encoded as specified by the current
661      * {@link net.sourceforge.jwebunit.util.TestContext}.
662      *
663      * @return Visible text in the page.
664      */
665     String getPageText();
666 
667     /**
668      * Return the source of the current page (like in a browser).
669      *
670      * @return Source of the page (or HTTP Body as String)
671      */
672     String getPageSource();
673 
674     /**
675      * Return the page title of the current response page, encoded as specified by the current
676      * {@link net.sourceforge.jwebunit.util.TestContext}.
677      *
678      * @return Title of the page.
679      */
680     String getPageTitle();
681 
682     /**
683      * Return the response of the server for the current page.
684      *
685      * @return HTTP header & body
686      */
687     String getServerResponse();
688 
689     /**
690      * Gets the last server response as input stream.
691      *
692      */
693     InputStream getInputStream();
694 
695     /**
696      * Gets the input stream for a given URL - can be used to test images or other resources without changing the current
697      * navigation context.
698      *
699      * @param url the url to the resource
700      */
701     InputStream getInputStream(URL url)
702             throws TestingEngineResponseException;
703 
704     /**
705      * Check if the Table object representing a specified table exists.
706      *
707      * @param tableSummaryNameOrId summary, name or id of the table.
708      * @return true if table exists.
709      */
710     boolean hasTable(String tableSummaryNameOrId);
711 
712     /**
713      * Each framework have it's own way to represent a Table. Testing engines are responsible for converting to the unified
714      * JWebUnit format.
715      *
716      * @param tableSummaryNameOrId summary, name or id of the table to return.
717      * @return unified JWebUnit representation of a table.
718      */
719     Table getTable(String tableSummaryNameOrId);
720 
721     /**
722      * Return true if a link is present in the current response containing the specified text.
723      *
724      * @param linkText text to check for in links on the response.
725      * @param index The 0-based index, when more than one link with the same text is expected.
726      */
727     boolean hasLinkWithText(String linkText, int index);
728 
729     /**
730      * Return true if a link is present in the current page containing the exact specified text. Note. This will call
731      * String.trim() to trim all leading / trailing spaces.
732      *
733      * RFE 996031...
734      *
735      * @param linkText text to check for in links on the response.
736      * @param index The 0-based index, when more than one link with the same text is expected.
737      */
738     boolean hasLinkWithExactText(String linkText, int index);
739 
740     /**
741      * Return true if a link is present with a given image based on filename of image.
742      *
743      * @param imageFileName A suffix of the image's filename; for example, to match
744      *            <tt>"images/my_icon.png"<tt>, you could just pass in
745      *                      <tt>"my_icon.png"<tt>.
746      * @param index
747      *            The 0-based index, when more than one link with the same text
748      *            is expected.
749      */
750     boolean hasLinkWithImage(String imageFileName, int index);
751 
752     /**
753      * Return true if a link is present in the current response with the specified id.
754      *
755      * @param anId link id to check for.
756      */
757     boolean hasLink(String anId);
758 
759     /**
760      * Navigate by submitting a request based on a link containing the specified text. A RuntimeException is thrown if
761      * no such link can be found.
762      *
763      * @param linkText text which link to be navigated should contain.
764      * @param index The 0-based index, when more than one link with the same text is expected.
765      */
766     void clickLinkWithText(String linkText, int index);
767 
768     /**
769      * Navigate by clicking a link with the exact specified text. A RuntimeException is thrown if no such link can be
770      * found.
771      *
772      * @param linkText exact text which link to be navigated should contain.
773      * @param index The 0-based index, when more than one link with the same text is expected.
774      */
775     void clickLinkWithExactText(String linkText, int index);
776 
777     /**
778      * Navigate by submitting a request based on a link with a given ID. A RuntimeException is thrown if no such link
779      * can be found.
780      *
781      * @param anID id of link to be navigated.
782      */
783     void clickLink(String anID);
784 
785     /**
786      * Navigate by submitting a request based on a link with a given image file name. A RuntimeException is thrown if no
787      * such link can be found.
788      *
789      * @param imageFileName A suffix of the image's filename; for example, to match <tt>"images/my_icon.png"</tt>,
790      *            you could just pass in <tt>"my_icon.png"</tt>.
791      * @param index The 0-based index, when more than one link with the same text is expected.
792      */
793     void clickLinkWithImage(String imageFileName, int index);
794 
795     /**
796      * Test if element with given id exists.
797      *
798      * @param anID id of the element.
799      * @return true if element was found.
800      */
801     boolean hasElement(String anID);
802 
803     /**
804      * Test if element with given xpath exists.
805      *
806      * @param xpath xpath of the element.
807      * @return true if element was found.
808      */
809     boolean hasElementByXPath(String xpath);
810 
811     /**
812      * Click element with given xpath.
813      *
814      * @param xpath xpath of the element.
815      */
816     void clickElementByXPath(String xpath);
817 
818     /**
819      * Get attribut value of the given element. For example, if you have img src="bla.gif" alt="toto",
820      * getElementAttributByXPath("//img[@src='bla.gif']", "alt") returns "toto"
821      *
822      * @param xpath xpath of the element.
823      * @param attribut name of the attribut.
824      * @return Attribut value or null if the element is not found.
825      */
826     String getElementAttributByXPath(String xpath, String attribut);
827 
828     /**
829      * Get text of the given element.
830      *
831      * @param xpath xpath of the element.
832      */
833     String getElementTextByXPath(String xpath);
834 
835 
836     /**
837      * Return true if a given string is contained within the specified element.
838      *
839      * @param elementID ID of element to inspect.
840      * @param text text to check for.
841      * @return true if text was found.
842      */
843     boolean isTextInElement(String elementID, String text);
844 
845     /**
846      * Return true if a given regexp is contained within the specified element.
847      *
848      * @param elementID Id of element to inspect.
849      * @param regexp regexp to match.
850      * @return true if a match is found.
851      */
852     boolean isMatchInElement(String elementID, String regexp);
853 
854     /**
855      * Tell the testing engine that the given alert boxes are expected in the given order.
856      *
857      * @param alerts Expected alerts.
858      * @throws ExpectedJavascriptAlertException If there are still unconsummed alert since a previous call of this
859      *             method.
860      */
861     void setExpectedJavaScriptAlert(JavascriptAlert[] alerts)
862             throws ExpectedJavascriptAlertException;
863 
864     /**
865      * Tell the testing engine that the given confirm boxes are expected in the given order.
866      *
867      * @param confirms Expected confirms.
868      * @throws ExpectedJavascriptConfirmException If there are still unconsummed confirm since a previous call of this
869      *             method.
870      */
871     void setExpectedJavaScriptConfirm(JavascriptConfirm[] confirms)
872             throws ExpectedJavascriptConfirmException;
873 
874     /**
875      * Tell the testing engine that the given prompt boxes are expected in the given order.
876      *
877      * @param prompts Expected prompts.
878      * @throws ExpectedJavascriptPromptException If there are still unconsummed prompt since a previous call of this
879      *             method.
880      */
881     void setExpectedJavaScriptPrompt(JavascriptPrompt[] prompts)
882             throws ExpectedJavascriptPromptException;
883 
884   /**
885    * Get an element wrapper for a given xpath.
886    *
887    * @see #getElementsByXPath(String)
888    * @param xpath XPath to evaluate
889    * @return The element if found
890    */
891   IElement getElementByXPath(String xpath);
892 
893   /**
894    * Get an element wrapper for a given ID.
895    *
896    * @param id element ID to find
897    * @return The element if found
898    */
899   IElement getElementByID(String id);
900 
901   /**
902    * Get a list of all elements that match the given xpath.
903    *
904    * @see #getElementByXPath(String)
905    * @param xpath XPath to evaluate
906    * @return List of all elements found
907    */
908   List<IElement> getElementsByXPath(String xpath);
909 
910   /**
911    * Get the request response code.
912    *
913    * @return The request response code.
914    */
915   int getServerResponseCode();
916 
917   /**
918    * Get a particular header or null.
919    *
920    * @param name The header name
921    * @return The first header value or null
922    */
923   String getHeader(String name);
924 
925     /**
926      * Get all distinct response headers. In case there are duplicate headers with same name, the last one will be returned.
927      *
928      * @return The header values stored in a map.
929      * @deprecated Use {@link #getResponseHeaders()}
930      */
931     @Deprecated
932     Map<String, String> getAllHeaders();
933 
934     /**
935      * Get all response headers.
936      * @return the response headers as a list of {@link HttpHeader}s
937      */
938     List<HttpHeader> getResponseHeaders();
939 
940     /**
941      * Should the tester ignore failing status codes (300+)? Otherwise,
942      * failing status codes will throw an exception.
943      *
944      * @param ignore
945      */
946     public void setIgnoreFailingStatusCodes(boolean ignore);
947 
948     /**
949      * Get all the comments in a document, as a list of strings.
950      */
951     public List<String> getComments();
952 
953     /**
954      * Set the timeout for the request. A timeout of 0 means
955      * an infinite timeout.
956      *
957      * @param milliseconds the milliseconds in which to timeout, or 0 for infinite
958      * wait (the default).
959      */
960     public void setTimeout(int milliseconds);
961 
962 }