|
18 | 18 |
|
19 | 19 | import static com.google.common.base.Preconditions.checkArgument; |
20 | 20 | import static com.google.common.base.Preconditions.checkNotNull; |
| 21 | +import static org.openqa.selenium.remote.CapabilityType.PLATFORM_NAME; |
21 | 22 |
|
22 | 23 | import com.google.common.collect.ImmutableList; |
23 | 24 | import com.google.common.collect.ImmutableMap; |
|
29 | 30 | import org.apache.commons.io.FileUtils; |
30 | 31 | import org.apache.commons.lang3.StringUtils; |
31 | 32 | import org.apache.commons.validator.routines.InetAddressValidator; |
| 33 | +import org.openqa.selenium.Capabilities; |
32 | 34 | import org.openqa.selenium.Platform; |
33 | 35 | import org.openqa.selenium.os.CommandLine; |
| 36 | +import org.openqa.selenium.remote.BrowserType; |
34 | 37 | import org.openqa.selenium.remote.DesiredCapabilities; |
35 | 38 | import org.openqa.selenium.remote.service.DriverService; |
36 | 39 |
|
@@ -96,6 +99,31 @@ public AppiumServiceBuilder() { |
96 | 99 | withEnvironment(System.getenv()); |
97 | 100 | } |
98 | 101 |
|
| 102 | + /** |
| 103 | + * Provides a measure of how strongly this {@link DriverService} supports the given |
| 104 | + * {@code capabilities}. A score of 0 or less indicates that this {@link DriverService} does not |
| 105 | + * support instances of {@link org.openqa.selenium.WebDriver} that require {@code capabilities}. |
| 106 | + * Typically, the score is generated by summing the number of capabilities that the driver |
| 107 | + * service directly supports that are unique to the driver service (that is, things like |
| 108 | + * "{@code proxy}" don't tend to count to the score). |
| 109 | + * Higher the score, higher the possibility of getting grid sessions created sooner. |
| 110 | + */ |
| 111 | + @Override public int score(Capabilities capabilites) { |
| 112 | + int score = 0; |
| 113 | + |
| 114 | + if (capabilites.getCapability(PLATFORM_NAME) != null) { |
| 115 | + score++; |
| 116 | + } |
| 117 | + |
| 118 | + String browserName = capabilites.getBrowserName(); |
| 119 | + if (browserName.equals(BrowserType.CHROME) || browserName.equals(BrowserType.ANDROID) |
| 120 | + || browserName.equals(BrowserType.SAFARI)) { |
| 121 | + score++; |
| 122 | + } |
| 123 | + |
| 124 | + return score; |
| 125 | + } |
| 126 | + |
99 | 127 | private static void validateNodeStructure(File node) { |
100 | 128 | String absoluteNodePath = node.getAbsolutePath(); |
101 | 129 |
|
|
0 commit comments