Unable to Cast Object Of Type Jvalue To String Or Syntax Error Thrown In The Selector

How to resolve the error "Unable to Cast Object of type Jvalue to String" or "Message: Syntax error in the selector" ?

Error Image:



Resolution: This exception could occur in any activity even a click activity, where a variable is used in selector.

When this variable takes dynamic values from say an excel, the values might contain single quotes ('). Hence, when this is used as a attribute value in selectors (aaname'"+variable+"'") the single quotes from the variable is taken as the end of attribute value.

  • Check if the value mentioned in the variable used for the selector has apostrophe in it. If yes then replace it with ' or ? or * like (aaname'"+variable.Replace("'","'")+"'")

For example: For name le'Demouir pass either le'Demouir or le?Demouir or le*Demouir