Usha
Usha

Reputation: 1

How to find open and closing braces present in a string (a list converted into string)?

My requirement is to check whether the input is list or not using robot framework.

I tried using type(${temp}).name with evaluate function, which works in case of list and fails for string type.

Below is the error message -

Evaluating expression 'type(testdata).name' failed: SyntaxError: invalid token (, line 1)

Tried to use regex, but no luck.:(

Code :- testRegEx ${match} Run Keyword Should Match Regexp ["swerwv","sfsdfdsf","edsfdf"] \[\s\S\] Log To Console ${match}

output:- FAIL : '["swerwv","sfsdfdsf","edsfdf"]' does not match '[\s\S]'

I'm new to robotframework. Any help would be appreciated.

Upvotes: 0

Views: 579

Answers (1)

Bryan Oakley
Bryan Oakley

Reputation: 386230

My requirement is to check whether the input is list or not using robot framework.

You can use robot's special syntax for evaluate and the various keywords which accept expressions, where you omit the brackets in the variable reference to pass the actual variable to the expression (versus passing the value of the variable).

Example:

*** Variables ***
@{a_list}      one  two  three

*** Test Cases ***
Test that variable is a list
    run keyword unless  type(a_list) == list
    ...   Fail   not a list

This feature is mentioned in the Evaluating expressions section of the built-in library.

Upvotes: 1

Related Questions