121
121
import com .google .common .collect .Maps ;
122
122
import com .google .common .collect .Sets ;
123
123
124
+ /**
125
+ * An implementation of {@link WebDriver} that drives <a href="http://htmlunit.sourceforge.net/">HtmlUnit</a>,
126
+ * which is a headless (GUI-less) browser simulator.
127
+ * <p>The main supported browsers are Chrome, Firefox and Internet Explorer.
128
+ */
124
129
public class HtmlUnitDriver implements WebDriver , JavascriptExecutor ,
125
130
FindsById , FindsByLinkText , FindsByXPath , FindsByName , FindsByCssSelector ,
126
131
FindsByTagName , FindsByClassName , HasCapabilities , HasInputDevices {
@@ -144,6 +149,11 @@ public class HtmlUnitDriver implements WebDriver, JavascriptExecutor,
144
149
public static final String INVALIDSELECTIONERROR =
145
150
"The xpath expression '%s' selected an object of type '%s' instead of a WebElement" ;
146
151
152
+ /**
153
+ * Constructs a new instance with the specified {@link BrowserVersion}.
154
+ *
155
+ * @param version the browser version to use
156
+ */
147
157
public HtmlUnitDriver (BrowserVersion version ) {
148
158
webClient = createWebClient (version );
149
159
currentWindow = webClient .getCurrentWindow ();
@@ -187,22 +197,35 @@ public void webWindowClosed(WebWindowEvent event) {
187
197
resetKeyboardAndMouseState ();
188
198
}
189
199
200
+ /**
201
+ * Constructs a new instance with JavaScript disabled,
202
+ * and the {@link BrowserVersion#getDefault() default} BrowserVersion.
203
+ */
190
204
public HtmlUnitDriver () {
191
205
this (false );
192
206
}
193
207
208
+ /**
209
+ * Constructs a new instance, specify JavaScript support
210
+ * and using the {@link BrowserVersion#getDefault() default} BrowserVersion.
211
+ *
212
+ * @param enableJavascript whether to enable JavaScript support or not
213
+ */
194
214
public HtmlUnitDriver (boolean enableJavascript ) {
195
215
this (BrowserVersion .getDefault ());
196
216
setJavascriptEnabled (enableJavascript );
197
217
}
198
218
199
219
/**
200
- * Note: There are two configuration modes for the HtmlUnitDriver using this constructor. The
201
- * first is where the browserName is "firefox", "internet explorer" and browserVersion denotes the
202
- * desired version. The second one is where the browserName is "htmlunit" and the browserVersion
203
- * denotes the required browser AND its version. In this mode the browserVersion could either be
204
- * "firefox" for Firefox or "internet explorer-7" for IE 7. The Remote WebDriver uses the second
205
- * mode - the first mode is deprecated and should not be used.
220
+ * Note: There are two configuration modes for the HtmlUnitDriver using this constructor.
221
+ * <ol>
222
+ * <li>The first is where the browserName is "chrome", "firefox" or "internet explorer"
223
+ * and browserVersion denotes the desired version.</li>
224
+ * <li>The second one is where the browserName is "htmlunit" and the browserVersion
225
+ * denotes the required browser AND its version. In this mode the browserVersion could be
226
+ * "chrome" for Chrome, "firefox-31" for Firefox 31 or "internet explorer-11" for IE 11.</li>
227
+ * </ol>
228
+ * <p>The Remote WebDriver uses the second mode - the first mode is deprecated and should not be used.
206
229
*/
207
230
public HtmlUnitDriver (Capabilities capabilities ) {
208
231
this (determineBrowserVersion (capabilities ));
@@ -292,7 +315,7 @@ private WebClient createWebClient(BrowserVersion version) {
292
315
}
293
316
294
317
/**
295
- * Create the underlying webclient , but don't set any fields on it.
318
+ * Create the underlying WebClient , but don't set any fields on it.
296
319
*
297
320
* @param version Which browser to emulate
298
321
* @return a new instance of WebClient.
@@ -302,7 +325,7 @@ protected WebClient newWebClient(BrowserVersion version) {
302
325
}
303
326
304
327
/**
305
- * Child classes can override this method to customise the webclient that the HtmlUnit driver
328
+ * Child classes can override this method to customize the WebClient that the HtmlUnit driver
306
329
* uses.
307
330
*
308
331
* @param client The client to modify
0 commit comments