Skip to content

Commit 53fb1a0

Browse files
asashourbarancev
authored andcommitted
Improve Javadoc for HtmlUnitDriver
Signed-off-by: Alexei Barantsev <[email protected]>
1 parent 3e85462 commit 53fb1a0

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

Diff for: java/client/src/org/openqa/selenium/htmlunit/HtmlUnitDriver.java

+31-8
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@
121121
import com.google.common.collect.Maps;
122122
import com.google.common.collect.Sets;
123123

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+
*/
124129
public class HtmlUnitDriver implements WebDriver, JavascriptExecutor,
125130
FindsById, FindsByLinkText, FindsByXPath, FindsByName, FindsByCssSelector,
126131
FindsByTagName, FindsByClassName, HasCapabilities, HasInputDevices {
@@ -144,6 +149,11 @@ public class HtmlUnitDriver implements WebDriver, JavascriptExecutor,
144149
public static final String INVALIDSELECTIONERROR =
145150
"The xpath expression '%s' selected an object of type '%s' instead of a WebElement";
146151

152+
/**
153+
* Constructs a new instance with the specified {@link BrowserVersion}.
154+
*
155+
* @param version the browser version to use
156+
*/
147157
public HtmlUnitDriver(BrowserVersion version) {
148158
webClient = createWebClient(version);
149159
currentWindow = webClient.getCurrentWindow();
@@ -187,22 +197,35 @@ public void webWindowClosed(WebWindowEvent event) {
187197
resetKeyboardAndMouseState();
188198
}
189199

200+
/**
201+
* Constructs a new instance with JavaScript disabled,
202+
* and the {@link BrowserVersion#getDefault() default} BrowserVersion.
203+
*/
190204
public HtmlUnitDriver() {
191205
this(false);
192206
}
193207

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+
*/
194214
public HtmlUnitDriver(boolean enableJavascript) {
195215
this(BrowserVersion.getDefault());
196216
setJavascriptEnabled(enableJavascript);
197217
}
198218

199219
/**
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.
206229
*/
207230
public HtmlUnitDriver(Capabilities capabilities) {
208231
this(determineBrowserVersion(capabilities));
@@ -292,7 +315,7 @@ private WebClient createWebClient(BrowserVersion version) {
292315
}
293316

294317
/**
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.
296319
*
297320
* @param version Which browser to emulate
298321
* @return a new instance of WebClient.
@@ -302,7 +325,7 @@ protected WebClient newWebClient(BrowserVersion version) {
302325
}
303326

304327
/**
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
306329
* uses.
307330
*
308331
* @param client The client to modify

0 commit comments

Comments
 (0)