Created
July 9, 2015 08:13
-
-
Save serhatbolsu/40ca473991232c578173 to your computer and use it in GitHub Desktop.
Grid Capability Matcher for Appium deviceName
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package qualify.appium; | |
import org.openqa.grid.internal.utils.DefaultCapabilityMatcher; | |
import java.util.Map; | |
/** | |
* This class is for nodes to determine Capability Matching using deviceName. | |
* For Capability Matcher change: | |
* - java -jar QualifyMatcher.jar -role hub -capabilityMatcher qualify.appium.QualifyMatcher | |
*/ | |
public class QualifyMatcher extends DefaultCapabilityMatcher { | |
private final String deviceName = "deviceName"; | |
public boolean matches(Map<String, Object> nodeCapability, Map<String, Object> requestedCapability) { | |
boolean basicChecks = super.matches(nodeCapability, requestedCapability); | |
String device = (String) requestedCapability.get(deviceName); | |
if (! requestedCapability.containsKey(deviceName)){ | |
//If the user did not set the custom capability lets just return what the DefaultCapabilityMatcher | |
//would return. That way we are backward compatibility and is not breaking the default behavior of the | |
//grid | |
// return false; | |
return basicChecks; | |
} | |
System.out.println("Port to deviceName:" + device); | |
return nodeCapability.get(deviceName).equals(device); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment