Skip to content

Commit

Permalink
Fixed an issue reading the remote driver url
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Jul 27, 2022
1 parent c1e87fe commit e930b03
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import org.openqa.selenium.chromium.ChromiumOptions;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.safari.SafariOptions;

import java.net.MalformedURLException;
import java.net.URL;
Expand Down Expand Up @@ -76,23 +75,29 @@ public WebDriver newInstance(String options, EnvironmentVariables environmentVar

EnhanceCapabilitiesWithFixtures.using(fixtureProviderService).into(capabilities);
AddCustomDriverCapabilities.from(environmentVariables)
.withTestDetails(SupportedWebDriver.getDriverTypeFor(driverName), testOutcome)
.to(capabilities);
.withTestDetails(SupportedWebDriver.getDriverTypeFor(driverName), testOutcome)
.to(capabilities);
return new RemoteWebDriver(remoteUrl, capabilities);
}
}

private URL getRemoteUrlFrom(EnvironmentVariables environmentVariables) {
String remoteUrl = EnvironmentSpecificConfiguration
.from(environmentVariables)
.getOptionalProperty(ThucydidesSystemProperty.WEBDRIVER_REMOTE_URL)
.orElse(
getRemoteUrlFromFixtureClasses(environmentVariables).orElseThrow(
() -> new RemoteDriverConfigurationError("A webdriver.remote.url property must be defined when using a Remote driver.")
)
);

String remoteUrl = null;

try {
Optional<String> environmentDefinedRemoteUrl = EnvironmentSpecificConfiguration.from(environmentVariables).getOptionalProperty(ThucydidesSystemProperty.WEBDRIVER_REMOTE_URL);
if (environmentDefinedRemoteUrl.isPresent()) {
remoteUrl = environmentDefinedRemoteUrl.get();
} else {
Optional<String> remoteUrlDefinedInFixtureClasses = getRemoteUrlFromFixtureClasses(environmentVariables);
if (remoteUrlDefinedInFixtureClasses.isPresent()) {
remoteUrl = remoteUrlDefinedInFixtureClasses.get();
}
}
if (remoteUrl == null) {
throw new RemoteDriverConfigurationError("A webdriver.remote.url property must be defined when using a Remote driver.");
}
return new URL(remoteUrl);
} catch (MalformedURLException e) {
throw new RemoteDriverConfigurationError("Incorrectly formed webdriver.remote.url property: " + remoteUrl, e);
Expand Down

0 comments on commit e930b03

Please sign in to comment.