Skip to content

Commit

Permalink
Add new HtmlUnitDriver(BrowserVersion,boolean)
Browse files Browse the repository at this point in the history
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 <luke.semerau@gmail.com>
  • Loading branch information
asashour authored and lukeis committed Jul 2, 2015
1 parent 31956a1 commit 3cff5f0
Showing 1 changed file with 29 additions and 19 deletions.
48 changes: 29 additions & 19 deletions java/client/src/org/openqa/selenium/htmlunit/HtmlUnitDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,35 @@ public class HtmlUnitDriver implements WebDriver, JavascriptExecutor,
public static final String INVALIDSELECTIONERROR =
"The xpath expression '%s' selected an object of type '%s' instead of a WebElement";

/**
* Constructs a new instance with JavaScript disabled,
* and the {@link BrowserVersion#getDefault() default} BrowserVersion.
*/
public HtmlUnitDriver() {
this(false);
}

/**
* Constructs a new instance, specify JavaScript support
* and using the {@link BrowserVersion#getDefault() default} BrowserVersion.
*
* @param enableJavascript whether to enable JavaScript support or not
*/
public HtmlUnitDriver(boolean enableJavascript) {
this(BrowserVersion.getDefault(), enableJavascript);
}

/**
* Constructs a new instance with the specified {@link BrowserVersion} and the JavaScript support.
*
* @param version the browser version to use
* @param enableJavascript whether to enable JavaScript support or not
*/
public HtmlUnitDriver(BrowserVersion version, boolean enableJavascript) {
this(version);
setJavascriptEnabled(enableJavascript);
}

/**
* Constructs a new instance with the specified {@link BrowserVersion}.
*
Expand Down Expand Up @@ -197,25 +226,6 @@ public void webWindowClosed(WebWindowEvent event) {
resetKeyboardAndMouseState();
}

/**
* Constructs a new instance with JavaScript disabled,
* and the {@link BrowserVersion#getDefault() default} BrowserVersion.
*/
public HtmlUnitDriver() {
this(false);
}

/**
* Constructs a new instance, specify JavaScript support
* and using the {@link BrowserVersion#getDefault() default} BrowserVersion.
*
* @param enableJavascript whether to enable JavaScript support or not
*/
public HtmlUnitDriver(boolean enableJavascript) {
this(BrowserVersion.getDefault());
setJavascriptEnabled(enableJavascript);
}

/**
* Note: There are two configuration modes for the HtmlUnitDriver using this constructor.
* <ol>
Expand Down

0 comments on commit 3cff5f0

Please sign in to comment.