Skip to content

Commit

Permalink
added option to support window maximization on scenario execution
Browse files Browse the repository at this point in the history
  • Loading branch information
build-failure committed Oct 6, 2016
1 parent 0d4a99e commit 9e09a02
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]
### Added
- added configuration parameter that toggles window maximization before scenario execution

## [1.4.0]
### Added
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ java -jar <path to jar> -<argument name> [<argument value> ...]
| *takeScreenshots* | optional | Defines when to take screenshots: NEVER, ON_FAILURE, ON_EVERY_STEP | `ON_FAILURE` | `./` |
| *browser* | optional | A browser can be selected by passing this option when running JWebRobot. Please consider that some browsers require additional configuration parameters. WAML scenarios are executed with Mozilla Firefox per default. Firefox must be installed on the same machine. E.g.: Chrome does not provide embedded webdriver so that it has to be [downloaded manually](webdriver-chrome). The path to the downloaded executable has to be forwarded via the system property `webdriver.chrome.driver`. Of course, Chrome must be present on the same machine. | `firefox` | `chrome` |
| *reportPath* | optional | Path to which the report is written to. | `./report.yaml` | `./myreport.yaml` |
| *maximizeWindow* | optional | Toggles window maximization before scenario execution. | `false` | `true` |

## Expressions
Expression are evaluated by the awesome templating engine [freemarker]. The expression syntax and result may be tested using online [template-tester].
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ public class ConfigurationProperties {
@Parameter(names = "-browserLogLevel", description = "Log level at which browser logs are included into the reports.", required = false)
private String browserLogLevel = DEFAULT_BROWSER_LOG_LEVEL;

@Parameter(names = "-maximizeWindow", description = "Triggers window maximization.", required = false)
private String maximizeWindow = Boolean.FALSE.toString();

public List<String> getScenarioPaths() {
return scenarioPaths;
}
Expand Down Expand Up @@ -173,4 +176,12 @@ public Collection<String> getAllScenarioPaths(){
public void setScenarioPath(String scenarioPath) {
this.scenarioPath = scenarioPath;
}

public String getMaximizeWindow() {
return maximizeWindow;
}

public void setMaximizeWindow(String maximizeWindow) {
this.maximizeWindow = maximizeWindow;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ private void execute(GlobalExecutionContext context, Scenario scenario){
logger.info("Starting scenario {}...", scenario.getName());
WebDriver driver = webDriverProvider.createInstance(options.getWebDriverType());

if(options.isMaximizeWindow() == Boolean.TRUE){
driver.manage().window().maximize();
}

ScenarioExecutionContext scenarioExecutionContext = new ScenarioExecutionContext(context, scenario, driver);
try {
runScenario(scenario, scenarioExecutionContext);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package website.automate.jwebrobot.executor;

import static java.lang.Boolean.parseBoolean;

import website.automate.jwebrobot.ConfigurationProperties;
import website.automate.waml.report.io.model.LogEntry.LogLevel;

Expand Down Expand Up @@ -70,6 +72,8 @@ public static ScreenshotType findByName(String name) {

private LogLevel browserLogLevel;

private boolean maximizeWindow;

public static ExecutorOptions of(
ConfigurationProperties configurationProperties) {
ExecutorOptions executorOptions = new ExecutorOptions();
Expand All @@ -86,6 +90,7 @@ public static ExecutorOptions of(
executorOptions.setScreenshotType(ScreenshotType.findByName(configurationProperties.getScreenshotType()));
executorOptions.setScreenshotFormat(configurationProperties.getScreenshotFormat());
executorOptions.setBrowserLogLevel(LogLevel.valueOf(configurationProperties.getBrowserLogLevel().toUpperCase()));
executorOptions.setMaximizeWindow(parseBoolean(configurationProperties.getMaximizeWindow()));

return executorOptions;
}
Expand Down Expand Up @@ -161,4 +166,12 @@ public LogLevel getBrowserLogLevel() {
public void setBrowserLogLevel(LogLevel browserLogLevel) {
this.browserLogLevel = browserLogLevel;
}

public boolean isMaximizeWindow() {
return maximizeWindow;
}

public void setMaximizeWindow(boolean maximizeWindow) {
this.maximizeWindow = maximizeWindow;
}
}

0 comments on commit 9e09a02

Please sign in to comment.