@Test() public void getCapabilitiesTest() { DesiredCapabilities caps = new CapabilitiesLoader().getCapabilities(customCapabilities); String value = (String) caps.getCapability(stringParam); Assert.assertNotNull(value, "Unable to find '" + stringParam + "' capability!"); Assert.assertEquals(value, stringValue, "Returned capability value is not valid!"); Assert.assertTrue((Boolean) caps.getCapability(booleanParamTrue), "Returned capability value is not valid!"); Assert.assertFalse((Boolean) caps.getCapability(booleanParamFalse), "Returned capability value is not valid!"); Assert.assertNull(caps.getCapability(coreParam), coreParam + " is present among capabilities mistakenly!"); }
public DesiredCapabilities getCapabilities(String fileName) { DesiredCapabilities capabilities = new DesiredCapabilities(); LOGGER.info("Generating capabilities from " + fileName); Properties props = loadProperties(fileName); final String prefix = SpecialKeywords.CAPABILITIES + "."; @SuppressWarnings({ "rawtypes", "unchecked" }) Map<String, String> capabilitiesMap = new HashMap(props); for (Map.Entry<String, String> entry : capabilitiesMap.entrySet()) { if (entry.getKey().toLowerCase().startsWith(prefix)) { String value = entry.getValue(); if (!value.isEmpty()) { String cap = entry.getKey().replaceAll(prefix, ""); if ("false".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: false"); capabilities.setCapability(cap, false); } else if ("true".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: true"); capabilities.setCapability(cap, true); } else { LOGGER.debug("Set capabilities value as string: " + value); capabilities.setCapability(cap, value); } } } } return capabilities; }
CapabilitiesLoader { public DesiredCapabilities getCapabilities(String fileName) { DesiredCapabilities capabilities = new DesiredCapabilities(); LOGGER.info("Generating capabilities from " + fileName); Properties props = loadProperties(fileName); final String prefix = SpecialKeywords.CAPABILITIES + "."; @SuppressWarnings({ "rawtypes", "unchecked" }) Map<String, String> capabilitiesMap = new HashMap(props); for (Map.Entry<String, String> entry : capabilitiesMap.entrySet()) { if (entry.getKey().toLowerCase().startsWith(prefix)) { String value = entry.getValue(); if (!value.isEmpty()) { String cap = entry.getKey().replaceAll(prefix, ""); if ("false".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: false"); capabilities.setCapability(cap, false); } else if ("true".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: true"); capabilities.setCapability(cap, true); } else { LOGGER.debug("Set capabilities value as string: " + value); capabilities.setCapability(cap, value); } } } } return capabilities; } }
CapabilitiesLoader { public DesiredCapabilities getCapabilities(String fileName) { DesiredCapabilities capabilities = new DesiredCapabilities(); LOGGER.info("Generating capabilities from " + fileName); Properties props = loadProperties(fileName); final String prefix = SpecialKeywords.CAPABILITIES + "."; @SuppressWarnings({ "rawtypes", "unchecked" }) Map<String, String> capabilitiesMap = new HashMap(props); for (Map.Entry<String, String> entry : capabilitiesMap.entrySet()) { if (entry.getKey().toLowerCase().startsWith(prefix)) { String value = entry.getValue(); if (!value.isEmpty()) { String cap = entry.getKey().replaceAll(prefix, ""); if ("false".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: false"); capabilities.setCapability(cap, false); } else if ("true".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: true"); capabilities.setCapability(cap, true); } else { LOGGER.debug("Set capabilities value as string: " + value); capabilities.setCapability(cap, value); } } } } return capabilities; }  }
CapabilitiesLoader { public DesiredCapabilities getCapabilities(String fileName) { DesiredCapabilities capabilities = new DesiredCapabilities(); LOGGER.info("Generating capabilities from " + fileName); Properties props = loadProperties(fileName); final String prefix = SpecialKeywords.CAPABILITIES + "."; @SuppressWarnings({ "rawtypes", "unchecked" }) Map<String, String> capabilitiesMap = new HashMap(props); for (Map.Entry<String, String> entry : capabilitiesMap.entrySet()) { if (entry.getKey().toLowerCase().startsWith(prefix)) { String value = entry.getValue(); if (!value.isEmpty()) { String cap = entry.getKey().replaceAll(prefix, ""); if ("false".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: false"); capabilities.setCapability(cap, false); } else if ("true".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: true"); capabilities.setCapability(cap, true); } else { LOGGER.debug("Set capabilities value as string: " + value); capabilities.setCapability(cap, value); } } } } return capabilities; }  void loadCapabilities(String fileName); void loadCapabilities(String fileName, boolean currentTestOnly); DesiredCapabilities getCapabilities(String fileName); }
CapabilitiesLoader { public DesiredCapabilities getCapabilities(String fileName) { DesiredCapabilities capabilities = new DesiredCapabilities(); LOGGER.info("Generating capabilities from " + fileName); Properties props = loadProperties(fileName); final String prefix = SpecialKeywords.CAPABILITIES + "."; @SuppressWarnings({ "rawtypes", "unchecked" }) Map<String, String> capabilitiesMap = new HashMap(props); for (Map.Entry<String, String> entry : capabilitiesMap.entrySet()) { if (entry.getKey().toLowerCase().startsWith(prefix)) { String value = entry.getValue(); if (!value.isEmpty()) { String cap = entry.getKey().replaceAll(prefix, ""); if ("false".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: false"); capabilities.setCapability(cap, false); } else if ("true".equalsIgnoreCase(value)) { LOGGER.debug("Set capabilities value as boolean: true"); capabilities.setCapability(cap, true); } else { LOGGER.debug("Set capabilities value as string: " + value); capabilities.setCapability(cap, value); } } } } return capabilities; }  void loadCapabilities(String fileName); void loadCapabilities(String fileName, boolean currentTestOnly); DesiredCapabilities getCapabilities(String fileName);  }