Hi,
I want to create a dynamic XPath in robot Framework
Varaibles
${nameOFFile}=. xpath://span[text()=‘${File_name}’]
Here, instead of {File_name} I want to pass the actual file name from the Test case level.
How can I achieve parameterized xpath in a robot framework?
Note: I am using python.
Thanks in advance.
When using the Variables section, they are evaluated when test is started, so what you want is to define the variable in a called user keyword or test step. Like this:
${nameOFFile}= Set Variable xpath://span[text()=‘${File_name}’]
1 Like
Thanks for the quick reply
Based on my understanding I have written code like below
Click on file
[Arguments] ${File_name}
${nameOFFile}= Set Variable xpath://span[text()=‘${File_name}’]
Wait And Click Element ${nameOFFile}
am I correct?
I think so.
It’s a matter of testing
In this case you don’t need to assign to a variable. You can do it directly:
Click on file
[Arguments] ${File_name}
Wait And Click Element xpath://span[text()='${File_name}']
1 Like