Search in sources :

Example 1 with JsonDataProvider

use of ru.sbtqa.tag.datajack.providers.json.JsonDataProvider in project page-factory-2 by sbtqa.

the class HtmlFindUtils method getElementTypesMap.

/**
 * Specifies a type map: type attribute, type. Data is taken from the json file specified in the 'ui.types' parameter
 *
 * @return Returns a type map
 */
public Map<String, Class> getElementTypesMap() {
    Map<String, Class> elements = new HashMap<>();
    try {
        String types = PROPERTIES.geUiTypes();
        String dir = types.substring(0, types.lastIndexOf("/"));
        String name = types.substring(types.lastIndexOf("/")).replace(".json", "");
        TestDataProvider dataObject = new JsonDataProvider(dir, name);
        for (String typeAttribute : dataObject.getKeySet()) {
            elements.put(typeAttribute, Class.forName(dataObject.get(typeAttribute).getValue()));
        }
    } catch (DataException | ClassNotFoundException ex) {
        throw new AutotestError("Error while generating element search types.", ex);
    }
    return elements;
}
Also used : AutotestError(ru.sbtqa.tag.qautils.errors.AutotestError) DataException(ru.sbtqa.tag.datajack.exceptions.DataException) TestDataProvider(ru.sbtqa.tag.datajack.TestDataProvider) HashMap(java.util.HashMap) JsonDataProvider(ru.sbtqa.tag.datajack.providers.json.JsonDataProvider)

Aggregations

HashMap (java.util.HashMap)1 TestDataProvider (ru.sbtqa.tag.datajack.TestDataProvider)1 DataException (ru.sbtqa.tag.datajack.exceptions.DataException)1 JsonDataProvider (ru.sbtqa.tag.datajack.providers.json.JsonDataProvider)1 AutotestError (ru.sbtqa.tag.qautils.errors.AutotestError)1