Search code examples
xpathautomationautomated-testsrobotframework

Click Element Robot Framework case sensitive


I have the same button in two different application , so i want to write the same code for them , but the pb is that there's a difference between the xpaths in the text , one starts with an uppercase letter and the second all in lower case :

xpath1: //span[contains(@class,'text')][contains(text(),'Test')]
xpath2: //span[contains(@class,'text')][contains(text(),'test')]

so i want to use the same function: Click Element    ${element}
for both apps , how to do that ?

THANKS


Solution

  • I'm using below format, it works perfect. So you can have multiple xpath using this union operator "|". There are also multiple options, but this works and easy to use.

    //span[contains(@class,'text')][contains(text(),'Test')] | //span[contains(@class,'text')][contains(text(),'test')]
    

    or you can also use below format, but this looks little dirty.

    //span[contains(@class,'text')][contains(text(),'Test') or contains(text(),"test")]