Using an If to check that a string contains a certain substring

I’m new to Kantu and one of the things I’m trying to do with my first macro is click a certain area of the screen based on some text that is already there. I’ve stored the string in a variable (Description) and I now want to check it for a substring using an if statement. I’ve been trying several different ways to use a contains function, but I’m apparently failing to hit the right syntax.

So, what should my condition (Target:) be for the if statement if I want it to evaluate true when the variable includes the number 110?

Here is a code snippet to check that a string contains a certain substring. I copied the code from the DemoPDFTest_with_OCR macro that ships with Kantu.

      "Command": "storeEval",
      "Target": "var string = \"${q}\", substring = \"110\";  b= string.includes(substring); b;",
      "Value": "textfound"

Thank you! I went through several of the demos, but I don’t think I went through that one. I appreciate the help!

Update: Since UI.Vision Version 4 and newer, the easier solution is to use executeScript command and the Javascript .includes feature to check that a string contains a certain substring (“string comparison”):

  "Name": "includes",
  "CreationDate": "2019-6-24",
  "Commands": [
      "Command": "store",
      "Target": "test tim meyer",
      "Value": "e"
      "Command": "if_v2",
      "Target": "${e}.includes (\"tim\") == true",
      "Value": ""
      "Command": "echo",
      "Target": "yes, it contains this string",
      "Value": "blue"
      "Command": "end",
      "Target": "",
      "Value": ""

this is not working for me. When I set the if_v2 target to:

${!SCRAPE}.includes (“test”) == true

to search the variable SCRAPE for the word “test” I get this:


Line 31: Error in condition of if_v2: Invalid or unexpected token.

What am I doing wrong?

Your personal variables must not include ! - the ! symbol is reserved for the internal variables.

Hello, Happy New Year!
This command works like charm, but when we have a substring with some accent, like “Orange-PP”, the Macro can’t handle due “-” character and simply ignore. How can we fix this? Thanks!

See also Selenium IDE string operations with executeScript_Sandbox - it has examples for removing characters from string.