Forum Discussion

Kinna's avatar
Kinna
Senior Member
5 years ago
Solved

String Comparion in Code Expression for Keyword Test within Visual Basic project suite

RESOLVED:  When using in the IF ... THEN Keyword test statement, must be Code expression with double quote mark before and after the string when not in a variable.

 

In a Keyword test after setting a variable with data from the page page, I'd like to know if that variable contains

"error", or "blocked" or "can't" or "unauthorized".

In the Set Variable or IF...THEN statements can choose Code Expression, but

For example, this one works:  REPLACE(KeywordTests.Tour_Lowest_Price.Variables.Lowest_Price, "$", "")

But these don't"

aqString.FIND(ProjectSuite.Variables.Browser_Tab_Title,"not exist",1)

FIND(ProjectSuite.Variables.Browser_Tab_Title,"not exist",1),

INSTR(ProjectSuite.Variables.Browser_Tab_Title,"not exist",1)

 

Is there a list of supported visual basic string functions to be used via the Code Expression field.

 

  • aqString.Find should work as a code expression.  Keep in mind, it returns an integer value that if it's a value of anything other than -1, the string is found.  So, you need to make sure you build your logic in the keyword test appropriately.

     

    If you can provide a screenshot of what you have implemented, we can help you figure out what's missing.

1 Reply

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor

    aqString.Find should work as a code expression.  Keep in mind, it returns an integer value that if it's a value of anything other than -1, the string is found.  So, you need to make sure you build your logic in the keyword test appropriately.

     

    If you can provide a screenshot of what you have implemented, we can help you figure out what's missing.