0

Trying to set a variable in an xpath that I can then replace the text in for a dropdown menu. Not sure if there is a better way to do this I have tried "Replace Variables" also from the String library but also fails. Any help would be appreciated.

Locator:

list_item = "xpath=//*[@id='testsection']//*[contains(concat(' ', @class, ' '), ' list-element ')][normalize-space(.) = '${REPLACETHIS}']"

Keyword:

Generate Locator For
    [Arguments]  ${locator}    ${REPLACETHIS}
    ${new_locator}=   Evaluate    ${locator}.format('${REPLACETHIS}')
    [Return]  ${new_locator}


Test
    ${new_locator}=    Generate Locator For    ${list_item}    default
    log to console  ${new_locator}

Result:

Evaluating expression 'xpath=//*[@id='test-section']//*[contains(concat(' ', @class, ' '), ' list-element ')][normalize-space(.) = '${REPLACETHIS}'].format('default')' failed: SyntaxError: invalid syntax (<string>, line 1)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.