Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to compare two strings equal or not in Robot Framework

How to compare two strings equal or not in Robot Framework. For example:

${xyz}=    Get Text    xpath=/html/body/div/div[2]/div[3]/div/div/div/div/h3
${abc}=    Get Text    xpath=/html/body/div/div[2]/div[4]/div/div/div/div/h3

These xpath values are getting different strings. So how to compare there strings equal or not?

Is it correct way to storing the values in variable in Robot Framework?

like image 314
Vamsi Reddy Avatar asked Dec 16 '22 08:12

Vamsi Reddy


1 Answers

Yes, that is the correct way of storing variables. Though you can also do it without the equal sign:

${xyz}    Get Text    xpath=/html/body/div/div[2]/div[3]/div/div/div/div/h3
${abc}    Get Text    xpath=/html/body/div/div[2]/div[4]/div/div/div/div/h3

Now that you have the two different strings assigned to variables, you can simply do:

Should Be Equal As Strings    ${xyz}    ${abc}

You can see the documentation for Should Be Equal As Strings here.

like image 170
mr2ert Avatar answered Dec 22 '22 03:12

mr2ert