Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,13 @@
<version>3.1</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-io -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-io</artifactId>
<version>1.3.2</version>
</dependency>

<!-- logging -->
<dependency>
<groupId>org.apache.logging.log4j</groupId>
Expand All @@ -187,4 +194,6 @@
<version>2.0.2</version>
</dependency>
</dependencies>


</project>
1 change: 1 addition & 0 deletions src/main/java/io/ddavison/conductor/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@
String hub() default "";
String baseUrl() default "";
String path() default "";
String options() default "";
}
2 changes: 2 additions & 0 deletions src/main/java/io/ddavison/conductor/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ public class Constants {
public static final String JVM_CONDUCTOR_BROWSER = "CONDUCTOR_BROWSER";
public static final String JVM_CONDUCTOR_HUB = "CONDUCTOR_HUB";
public static final String JVM_CONDUCTOR_BASE_URL = "CONDUCTOR_BASE_URL";
public static final String JVM_CONDUCTOR_OPTIONS = "CONDUCTOR_OPTIONS";

public static final String DEFAULT_PROPERTY_URL = "url";
public static final String DEFAULT_PROPERTY_BROWSER = "browser";
public static final String DEFAULT_PROPERTY_HUB = "hub";
public static final String DEFAULT_PROPERTY_BASE_URL = "base_url";
public static final String DEFAULT_OPTIONS = "options";
}
21 changes: 19 additions & 2 deletions src/main/java/io/ddavison/conductor/Locomotive.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
import org.junit.After;
import org.openqa.selenium.*;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.edge.EdgeDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
import org.openqa.selenium.ie.InternetExplorerDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.phantomjs.PhantomJSDriver;
Expand Down Expand Up @@ -138,8 +138,10 @@ public Locomotive() {
switch (configuration.browser()) {
case CHROME:
capabilities = DesiredCapabilities.chrome();

ChromeOptions options = getChromeOptions(configuration);
if (isLocal) try {
driver = new ChromeDriver(capabilities);
driver = new ChromeDriver(options);
} catch (Exception x) {
logFatal("Also see https://github.com/conductor-framework/conductor/wiki/WebDriver-Executables");
System.exit(1);
Expand Down Expand Up @@ -215,6 +217,21 @@ public Locomotive() {
if (StringUtils.isNotEmpty(baseUrl)) driver.navigate().to(baseUrl);
}

private ChromeOptions getChromeOptions(Config locoConfig) {
ChromeOptions options = new ChromeOptions();
if (StringUtils.isNotEmpty(locoConfig.options())) {
String[] splitOptions = locoConfig.options().split("\\s+");
List<String> lstOptions = new ArrayList<>();
for (String opt : splitOptions) {
lstOptions.add(opt);
}
lstOptions.add(locoConfig.options());
options.addArguments(lstOptions);
}

return options;
}

private String extractChromeDriver(Platform platform) throws IOException, RuntimeException {
return extractDriver(platform, "chrome");
}
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/io/ddavison/conductor/LocomotiveConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,21 @@ public String path() {
return path;
}

@Override
public String options() {
String opts = "";
if (!StringUtils.isEmpty(properties.getProperty(Constants.DEFAULT_OPTIONS))) {
opts = properties.getProperty(Constants.DEFAULT_OPTIONS);
}
if (testConfig != null && (!StringUtils.isEmpty(testConfig.options()))) {
opts = testConfig.options();
}
if (!StringUtils.isEmpty(JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_OPTIONS))) {
opts = JvmUtil.getJvmProperty(Constants.JVM_CONDUCTOR_OPTIONS);
}
return opts;
}

@Override
public Class<? extends Annotation> annotationType() {
return null;
Expand Down