-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Simplify browser configuration #10 -
configurations are now provided via Configuration class and stored in loginConfig and config respectively the configurations will then be applied in the beforeEach method. Configurations in loginConfig will be applied before calling login(), the once in config will be applied afterwards.
- Loading branch information
Daniel.Rey
committed
Oct 22, 2016
1 parent
e05ad0c
commit 6cc8180
Showing
9 changed files
with
303 additions
and
127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
core/src/main/scala/org/scalawebtest/core/Configuration.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package org.scalawebtest.core | ||
|
||
class Configuration() { | ||
var configurations: Map[String, WebClientExposingDriver => Unit] = Map() | ||
|
||
//initialize with sensible default configuration | ||
disableJavaScript() | ||
swallowJavaScriptErrors() | ||
disableCss() | ||
|
||
def enableJavaScript(throwOnError: Boolean): Unit = { | ||
configurations += "enableJavaScript" -> | ||
((webDriver: WebClientExposingDriver) => webDriver.getOptions.setJavaScriptEnabled(true)) | ||
configurations += "throwOnJSError" -> | ||
((webDriver: WebClientExposingDriver) => webDriver.getOptions.setThrowExceptionOnFailingStatusCode(throwOnError)) | ||
} | ||
|
||
def disableJavaScript(): Unit = { | ||
configurations += "enableJavaScript" -> ((webDriver: WebClientExposingDriver) => webDriver.getOptions.setJavaScriptEnabled(false)) | ||
configurations += "throwOnJSError" -> ((webDriver: WebClientExposingDriver) => webDriver.getOptions.setThrowExceptionOnFailingStatusCode(false)) | ||
} | ||
|
||
def throwOnJavaScriptError(): Unit = configurations += "throwOnJSError" -> | ||
((webDriver: WebClientExposingDriver) => webDriver.getOptions.setThrowExceptionOnFailingStatusCode(true)) | ||
|
||
def swallowJavaScriptErrors(): Unit = configurations += "throwOnJSError" -> | ||
((webDriver: WebClientExposingDriver) => webDriver.getOptions.setThrowExceptionOnFailingStatusCode(false)) | ||
|
||
def enableCss(): Unit = configurations += "enableCss" -> | ||
((webDriver: WebClientExposingDriver) => webDriver.getOptions.setCssEnabled(true)) | ||
|
||
def disableCss(): Unit = configurations += "enableCss" -> | ||
((webDriver: WebClientExposingDriver) => webDriver.getOptions.setCssEnabled(false)) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.