Skip to content

Commit 3cff5f0

Browse files
asashourlukeis
authored andcommitted
Add new HtmlUnitDriver(BrowserVersion,boolean)
Currently there is a constructor with BrowserVersion and another one with boolean (JS enabling), however must users use WebDriver driver = new HtmlUnitDriver() And in this case WebDriver doesn't have setBrowsreVersion/setJavascriptEnabled Signed-off-by: Luke Inman-Semerau <[email protected]>
1 parent 31956a1 commit 3cff5f0

File tree

1 file changed

+29
-19
lines changed

1 file changed

+29
-19
lines changed

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

+29-19
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,35 @@ public class HtmlUnitDriver implements WebDriver, JavascriptExecutor,
149149
public static final String INVALIDSELECTIONERROR =
150150
"The xpath expression '%s' selected an object of type '%s' instead of a WebElement";
151151

152+
/**
153+
* Constructs a new instance with JavaScript disabled,
154+
* and the {@link BrowserVersion#getDefault() default} BrowserVersion.
155+
*/
156+
public HtmlUnitDriver() {
157+
this(false);
158+
}
159+
160+
/**
161+
* Constructs a new instance, specify JavaScript support
162+
* and using the {@link BrowserVersion#getDefault() default} BrowserVersion.
163+
*
164+
* @param enableJavascript whether to enable JavaScript support or not
165+
*/
166+
public HtmlUnitDriver(boolean enableJavascript) {
167+
this(BrowserVersion.getDefault(), enableJavascript);
168+
}
169+
170+
/**
171+
* Constructs a new instance with the specified {@link BrowserVersion} and the JavaScript support.
172+
*
173+
* @param version the browser version to use
174+
* @param enableJavascript whether to enable JavaScript support or not
175+
*/
176+
public HtmlUnitDriver(BrowserVersion version, boolean enableJavascript) {
177+
this(version);
178+
setJavascriptEnabled(enableJavascript);
179+
}
180+
152181
/**
153182
* Constructs a new instance with the specified {@link BrowserVersion}.
154183
*
@@ -197,25 +226,6 @@ public void webWindowClosed(WebWindowEvent event) {
197226
resetKeyboardAndMouseState();
198227
}
199228

200-
/**
201-
* Constructs a new instance with JavaScript disabled,
202-
* and the {@link BrowserVersion#getDefault() default} BrowserVersion.
203-
*/
204-
public HtmlUnitDriver() {
205-
this(false);
206-
}
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-
*/
214-
public HtmlUnitDriver(boolean enableJavascript) {
215-
this(BrowserVersion.getDefault());
216-
setJavascriptEnabled(enableJavascript);
217-
}
218-
219229
/**
220230
* Note: There are two configuration modes for the HtmlUnitDriver using this constructor.
221231
* <ol>

0 commit comments

Comments
 (0)