Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: support RemoteWebDriver #353

Merged
merged 1 commit into from
Sep 16, 2020
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@
import com.github.searls.jasmine.mojo.Capability;
import org.immutables.value.Value;

import java.net.URL;
import java.util.List;

@Value.Immutable
public interface WebDriverConfiguration {
String getWebDriverClassName();
List<Capability> getWebDriverCapabilities();
URL getRemoteWebDriverUrl();
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.remote.DesiredCapabilities;
import org.openqa.selenium.remote.RemoteWebDriver;

import javax.inject.Named;
import java.lang.reflect.Constructor;
Expand All @@ -47,6 +48,7 @@ public class WebDriverFactory {
private static final Map<String, Function<WebDriverConfiguration, WebDriver>> SUPPORTED_DRIVERS =
ImmutableMap.<String, Function<WebDriverConfiguration, WebDriver>>builder()
.put(ChromeDriver.class.getName(), WebDriverFactory::createChromeDriver)
.put(RemoteWebDriver.class.getName(), WebDriverFactory::createRemoteWebDriver)
.build();

public WebDriver createWebDriver(WebDriverConfiguration config) {
Expand Down Expand Up @@ -157,4 +159,8 @@ private static WebDriver createChromeDriver(WebDriverConfiguration config) {
config
));
}

private static WebDriver createRemoteWebDriver(WebDriverConfiguration config) {
return new RemoteWebDriver(config.getRemoteWebDriverUrl(), getCapabilities(config.getWebDriverCapabilities()));
}
}
13 changes: 12 additions & 1 deletion src/main/java/com/github/searls/jasmine/mojo/TestMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.slf4j.LoggerFactory;

import javax.inject.Inject;
import java.net.URL;
import java.util.Collections;
import java.util.List;

Expand All @@ -67,13 +68,14 @@ public class TestMojo extends AbstractJasmineMojo {
* <li>org.openqa.selenium.htmlunit.HtmlUnitDriver</li>
* <li>org.openqa.selenium.firefox.FirefoxDriver</li>
* <li>org.openqa.selenium.ie.InternetExplorerDriver</li>
* <li>org.openqa.selenium.remote.RemoteWebDriver</li>
* </ul>
* <br>
* See the webDriverCapabilities property for configuring driver specific properties.
*
* @since 1.1.0
*/
@Parameter(defaultValue = "org.openqa.selenium.chrome.ChromeDriver")
@Parameter(property = "jasmine.webDriverClassName", defaultValue = "org.openqa.selenium.chrome.ChromeDriver")
private String webDriverClassName = ChromeDriver.class.getName();

/**
Expand Down Expand Up @@ -109,6 +111,14 @@ public class TestMojo extends AbstractJasmineMojo {
@Parameter
private List<Capability> webDriverCapabilities = Collections.emptyList();

/**
* <p>The URL to your RemoteWebDriver server. This is only relevant if you are using the RemoteWebDriver.</p>
*
* @since 3.0
*/
@Parameter(property = "jasmine.remoteWebDriverUrl", defaultValue = "http://localhost:4444/wd/hub")
private URL remoteWebDriverUrl = null;

/**
* <p>Determines the format that jasmine:test will print to console.</p>
* <p>Valid options:</p>
Expand Down Expand Up @@ -265,6 +275,7 @@ private WebDriverConfiguration getWebDriverConfiguration() {
return ImmutableWebDriverConfiguration.builder()
.webDriverCapabilities(webDriverCapabilities)
.webDriverClassName(webDriverClassName)
.remoteWebDriverUrl(remoteWebDriverUrl)
.build();
}

Expand Down