1   package com.atlassian.selenium;
2   
3   import com.thoughtworks.selenium.Selenium;
4   
5   
6   /**
7    * Extends the {@link Selenium} client to provide a more sensible implementation
8    * as well some extra utility methods such as keypress.
9    */
10  public interface SeleniumClient extends Selenium
11  {
12  
13      /**
14       * Unlike {@link DefaultSelenium#open}, this opens the provided URL relative to the application context path.
15       * It also waits for the page to load -- a maximum of PAGE_LOAD_WAIT before returning.
16       */
17      public void open(String url);
18  
19      /**
20       * Wait for page to load doesn't work the case of non-HTML based resources (like images).
21       * So sometimes you really do want to open a url without waiting.
22       * @param url
23       */
24      public void openNoWait(String url);
25  
26      /**
27       * Opens the given URL and waits a maximum of timeoutMillis for the page to load completely.
28       */
29      public void open(String url, long timeoutMillis);
30  
31      /**
32       * Overloads {@link #waitForPageToLoad(String)} to take in a long.
33       */
34      public void waitForPageToLoad(long timeoutMillis);
35  
36      /**
37       * Waits for the page to load with the default timeout configured in {@link SeleniumConfiguration}.
38       */
39      public void waitForPageToLoad();
40  
41      /**
42       * Executes the given Javascript in the context of the text page and waits for it to evaluate to true
43       * for a maximum of {@link SeleniumConfiguration.getActionWait} milliseconds.
44       * @see #waitForCondition(String, long) if you would like to specify your own timeout.
45       */
46      public void waitForCondition(String javascript);
47  
48      /**
49       * Executes the given Javascript in the context of the text page and waits for it to evaluate to true
50       * for a maximum of timeoutMillis.
51       */
52      public void waitForCondition(String javascript, long timeoutMillis);
53  
54      /**
55       * Waits for the page to finish loading ajax calls, and returns if there are no more ajax calls currently running.
56       * The method will check for a maximum of {@link #ACTION_WAIT} milliseconds
57       * @see #waitForAjaxWithJquery(long) if you would like to specify your own timeout.
58       */
59      public void waitForAjaxWithJquery();
60  
61      /**
62       * Waits for the page to finish loading ajax calls, and returns if there are no more ajax calls currently running.
63       * The method will check for a maximum of timeoutMillis
64       */
65      public void waitForAjaxWithJquery(long timeoutMillis);
66  
67      /**
68       * Click the element with the given locator and optionally wait for the page to load, using {@link #PAGE_LOAD_WAIT}.
69       *
70       * @param locator the element to click, specified using Selenium selector syntax
71       * @param waitForPageToLoad whether to wait for the page to reload. Don't use this unless the page is completely
72       * reloaded.
73       * @see #click(String, long) if you would like to specify your own timeout.
74       */
75      public void click(String locator, boolean waitForPageToLoad);
76  
77      /**
78       * Submit the named form locator and optionally wait for the page to load, using {@link #PAGE_LOAD_WAIT}.
79       *
80       * @param form to click, specified using Selenium selector syntax
81       * @param waitForPageToLoad whether to wait for the page to reload. Don't use this unless the page is completely
82       * reloaded.
83       * @see #submit(String, long) if you would like to specify your own timeout.
84       */
85      public void submit(String form, boolean waitForPageToLoad);
86  
87      /**
88       * Click the element with the given locator and wait for the page to load, for a maximum of timeoutMillis.
89       * <p/>
90       * Do not use this method if the page does not reload.
91       *
92       * @param locator the element to click, specified using Selenium selector syntax
93       * @param timeoutMillis the maximum number of milliseconds to wait for the page to load. Polling takes place
94       * more frequently.
95       * @see #click(String, boolean) if you would like to use the default timeout
96       */
97      public void click(String locator, long timeoutMillis);
98  
99      /**
100      * Click the element with the given locator and wait for the ajax call to finish.
101      *
102      * @param locator the element to click, specified using Selenium selector syntax
103      */
104     public void clickAndWaitForAjaxWithJquery(String locator);
105 
106     /**
107      * Click the element with the given locator and wait for the ajax call to finish.
108      *
109      * @param locator the element to click, specified using Selenium selector syntax
110      * @param timeoutMillis the maximum number of milliseconds to wait for the ajax calls to finish.
111      * @see #clickAndWaitForAjaxWithJquery(String) if you would like to use the default timeout
112      */
113     public void clickAndWaitForAjaxWithJquery(String locator, long timeoutMillis);
114 
115     /**
116      * Submit the given form and wait for the page to load, for a maximum of timeoutMillis.
117      * <p/>
118      * Do not use this method if the page does not reload.
119      *
120      * @param form the form to submit
121      * @param timeoutMillis the maximum number of milliseconds to wait for the page to load. Polling takes place
122      * more frequently.
123      * @see #click(String, boolean) if you would like to use the default timeout
124      */
125     public void submit(String form, long timeoutMillis);
126 
127     /**
128      * This will type into a field by sending key down / key press / key up events.
129      * @param locator Uses the Selenium locator syntax
130      * @param key The key to be pressed
131      */
132     public void keyPress(String locator, String key);
133 
134     /**
135      * This will type into a field by first blanking it out and then sending key down / key press / key up
136      * events.
137      *
138      * @param locator the Selenium locator
139      * @param string  the string to type
140      * @param reset   Should the field be reset first?
141      */
142     public void typeWithFullKeyEvents(String locator, String string, boolean reset);
143 
144     /**
145      * This will type into a field by first blanking it out and then sending key down / key press / key up
146      * events. This really only calls {@link #typeWithFullKeyEvents(String,String,boolean)})}
147      *
148      * @param locator - the usual Selenium locator
149      * @param string  the string to type into a field
150      */
151     public void typeWithFullKeyEvents(String locator, String string);
152 
153     /**
154      * This will select an option from a {@code select} field.
155      *
156      * @param selectName the select field name
157      * @param label the label to select
158      */
159     public void selectOption(String selectName, String label);
160 
161     /**
162      * This will select an option from a {@code select} field. If the field calls executes an ajax call onchange of
163      * the value, this method will wait for that ajax method to finish.
164      *
165      * @param selectName the select field name
166      * @param label the label to select
167      */
168     public void selectOptionAndWaitForAjaxWithJquery(String selectName, String label);
169 
170     /**
171      * Checks a checkbox given a name and value.
172      */
173     public void check(String name, String value);
174 
175     public void clickLinkWithText(String text, boolean waitForPageToLoad);
176 
177     public void clickButton(String buttonText, boolean waitForPageToLoad);
178 
179     public void clickButtonAndWaitForAjaxWithJquery(String buttonText);
180 
181     public void clickButtonWithName(String buttonName, boolean waitForPageToLoad);
182 
183     public void clickButtonWithNameAndWaitForAjaxWithJquery(String buttonName);
184 
185     public void clickElementWithTitle(String title);
186 
187     public void clickElementWithTitleAndWaitForAjaxWithJquery(String title);
188 
189     public void clickElementWithClass(String className);
190 
191     public void clickElementWithClassAndWaitForAjaxWithJquery(String className);
192 
193     public void clickElementWithCss(String cssSelector);
194 
195     public void clickElementWithCssAndWaitForAjaxWithJquery(String cssSelector);
196 
197     public void clickElementWithXpath(String xpath);
198 
199     public void clickElementWithXpathAndWaitForAjaxWithJquery(String xpath);
200 
201     public void typeInElementWithName(String elementName, String text);
202 
203     public void typeInElementWithCss(String cssSelector, String text);
204 
205     public boolean hasJquery();
206 
207     public void start();
208 
209     public Browser getBrowser();
210 
211     public void seleniumKeyPress(String locator, String key);
212 
213 }