Hi Machindra,
Now I’m finished work for the day had a bit of time to try it out, I took other libraries out of the equation and did a simple Robot Framework only test like this:
*** Variables ***
${xpath}= //div[text()='Work Type']/../../div/div/button[@disabled]
*** Test Cases ***
Machindras xpath
FOR ${row_index} IN RANGE 1 3+1
${updated_xpath}= Set Variable ${xpath}[${row_index}]
Log ${updated_xpath}
END
When I saw that it was immediately obvious what was happening, in python when you place square brackets after a string variable with a number inside the result is that character is returned (see Slicing Strings), so all you need to do is escape open the open square bracket like this:
*** Variables ***
${xpath}= //div[text()='Work Type']/../../div/div/button[@disabled]
*** Test Cases ***
Machindras xpath
FOR ${row_index} IN RANGE 1 3+1
${updated_xpath}= Set Variable ${xpath}\[${row_index}]
Log ${updated_xpath}
END
Hopefully that solves your issue,
Dave.

