All Downloads are FREE. Search and download functionalities are using the official Maven repository.

net.serenitybdd.screenplay.targets.TargetSelectorWithVariables Maven / Gradle / Ivy

There is a newer version: 4.2.8
Show newest version
package net.serenitybdd.screenplay.targets;

public class TargetSelectorWithVariables {
    private final String cssOrXPathSelector;

    public TargetSelectorWithVariables(String cssOrXPathSelector) {
        this.cssOrXPathSelector = cssOrXPathSelector;
    }

    public String resolvedWith(String[] parameters) {

        String instantiatedSelector = cssOrXPathSelector;

        int variableIndex = 0;
        for(String parameter : parameters) {
            String variablePlaceholder = "\\{" + variableIndex++ + "\\}";
            instantiatedSelector = instantiatedSelector.replaceAll(variablePlaceholder, parameter);
        }
        return instantiatedSelector;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy