public By getElementLocatorForElementReference(String elementReference, String apendix) {
    	Map<String, By> objectReferenceMap = getObjectReferenceMap(By.class);
    	
        By elementLocator = objectReferenceMap.get(elementReference);
        if (elementLocator instanceof ById) {
            String xpathExpression = elementLocator.toString().replaceAll("By.id: ", "//*[@id='") + "']" + apendix;
            elementLocator = By.xpath(xpathExpression);
        } else if (elementLocator instanceof ByXPath) {
            String xpathExpression = elementLocator.toString().replaceAll("By.xpath: ", "") + apendix;
            elementLocator = By.xpath(xpathExpression);
        } else {
            fail("ElementLocator conversion error");
        }

        if (elementLocator == null) {
            fail("No elementLocator is found for element name: '" + elementReference + "'. Available element references are: " + objectReferenceMap.keySet().toString());
        }
        return elementLocator;
    }
public By getElementLocatorForElementReference ( String elementReference , String apendix ) { Map < String , By > objectReferenceMap = getObjectReferenceMap ( By . class ) ; By elementLocator = objectReferenceMap . get ( elementReference ) ; if ( elementLocator instanceof ById ) { String xpathExpression = elementLocator . toString ( ) . replaceAll ( "By.id: " , "//*[@id='" ) + "']" + apendix ; elementLocator = By . xpath ( xpathExpression ) ; } else if ( elementLocator instanceof ByXPath ) { String xpathExpression = elementLocator . toString ( ) . replaceAll ( "By.xpath: " , "" ) + apendix ; elementLocator = By . xpath ( xpathExpression ) ; } else { fail ( "ElementLocator conversion error" ) ; } if ( elementLocator == null ) { fail ( "No elementLocator is found for element name: '" + elementReference + "'. Available element references are: " + objectReferenceMap . keySet ( ) . toString ( ) ) ; } return elementLocator ; }
Find a {@link By} locator by its reference name and add something to the xpath before the element gets returned
The drawback of using this method is, that all locators are converted into By.xpath

@param elementReference The name under which the refference is found
@param apendix The part of the xpath that shall be added
@return {@link By}