Katalon Recorder : If variable contains some text - True/False

1.8k views Asked by At

In Katalon Chrome addon or Selenium Chrome addon, I'm trying to set up a simple check to verify if an element contains a specific text.

Here is what I've done so far :

Katalon Recorder (Example):

Command | Target | Value

click | id=subscribed |

StoreText | id=subscribed | i

echo | ${i}

verifyText | id=subscribed | alyx

Log result :

[info] Executing: | click | id=subscribed | |

[info] Executing: | storeText | id=subscribed | i |

[info] Store 'alyx.vance' into 'i'

[info] Executing: | echo | ${i} | |

[info] Expand variable '${i}' into 'alyx.vance'

[info] echo: alyx.vance

[info] Executing: | verifyText | id=subscribed | alyx |

From here, how can I set up this? :

If VerifyText = alyx (Contains) => Goto Label X (True)

If VerifyText != alyx (Not Contains) => Goto Label Y (False)

Thank you for your help.

2

There are 2 answers

0
Vlad D. On

How about:

storeText | id=subscribed | i
store | alyx.vance | j
if | ${i} == ${j}
click | Label_X_locator
elseIf | ${i} != ${j}
click | Label_Y_locator
endIf
0
Fwed On

I've finaly found the solution and it works that way on my script :

Command | Target | Value

click | id=subscribed

StoreText | id=subscribed | i

echo | ${i}

storeText | alyx.vance | j

if | ('${i}').includes('${j}')

gotoLabel | X

else

gotoLabel | Y

...

endif

It works for me but in certain cases, it might not work so, if you need help :)