Skip to content

Commit

Permalink
Attempt to fix #3351
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Dec 15, 2023
1 parent 2578368 commit fb0e27d
Showing 1 changed file with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
import org.openqa.selenium.remote.RemoteWebDriver;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.List;
import java.util.Objects;
Expand All @@ -44,6 +46,8 @@ public RemoteDriverProvider(FixtureProviderService fixtureProviderService) {
public WebDriver newInstance(String options, EnvironmentVariables environmentVariables) {
if (StepEventBus.getParallelEventBus().webdriverCallsAreSuspended()) {
return RemoteWebdriverStub.from(environmentVariables);
} else if (isAppium(environmentVariables)) {
return new AppiumDriverProvider(fixtureProviderService).newInstance(options, environmentVariables);
} else {
//
// The remote url is defined in serenity.conf or can be defined in a class that implements ProvidesRemoteWebdriverUrl
Expand Down Expand Up @@ -83,6 +87,10 @@ public WebDriver newInstance(String options, EnvironmentVariables environmentVar
}
}

private boolean isAppium(EnvironmentVariables environmentVariables) {
return "appium".equalsIgnoreCase(WEBDRIVER_REMOTE_DRIVER.from(environmentVariables));
}

private URL getRemoteUrlFrom(EnvironmentVariables environmentVariables) {

String remoteUrl = null;
Expand All @@ -100,8 +108,8 @@ private URL getRemoteUrlFrom(EnvironmentVariables environmentVariables) {
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) {
return new URI(remoteUrl).toURL();
} catch (MalformedURLException | URISyntaxException e) {
throw new RemoteDriverConfigurationError("Incorrectly formed webdriver.remote.url property: " + remoteUrl, e);
}
}
Expand Down

0 comments on commit fb0e27d

Please sign in to comment.