I have this code snippet
*** Keywords ***
My Keyword
[Arguments] ${arg}
${xpath} Set Variable really long dynamic xpath using ${arg}
Do Something With ${xpath}
etc.
My Other Keyword
[Arguments] ${arg}
${xpath} Set Variable really long dynamic xpath using ${arg}
Do Something Totally Different With ${xpath}
etc.
To follow programming best practices, I want to have the xpath (the same in both keywords) defined at single place only. I tried to modify it like this
*** Variables ***
${xpath_template} really long dynamic xpath using ${arg}
*** Keywords ***
My Keyword
[Arguments] ${arg}
${xpath} Evaluate ${xpath_template}
Do Something With ${xpath}
etc.
My Other Keyword
[Arguments] ${arg}
${xpath} Evaluate ${xpath_template}
Do Something Totally Different With ${xpath}
etc.
In other words, I need the substitution of ${arg}
in ${xpath_template}
be defered until the moment ${arg}
is defined. However, the code above does not perform it, nor my similar experiments when I tried to force Set Variable
or ${{...}}
to do it for me... Can you help me, please, to have the xpath be only once in my code?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…