asyrjasalo / RESTinstance

Robot Framework library for RESTful JSON APIs
https://asyrjasalo.github.io/RESTinstance
GNU Lesser General Public License v3.0
204 stars 84 forks source link

wrong response #100

Closed allen1986 closed 2 years ago

allen1986 commented 4 years ago

I got wrong response when use RESTInstance GET method, the response contains some weird chracter seems like color code. below is test case and response:

*** Settings ***
Library           REST      http://localhost:8085

*** Test Cases ***
GET token from server
    GET     /token
    Output     $.code
    Should Be Equal As Strings     $.code      40001
================================================================
Test
================================================================
GET token from server                                                 .
?[34m40001?[39;49;00m
GET token from server                                                 | FAIL |
$.code != 40001
------------------------------------------------------------------------------
Test                                                                  | FAIL |
1 critical test, 0 passed, 1 failed
1 test total, 0 passed, 1 failed
================================================================
asimell commented 3 years ago

Hi @allen1986

Should Be Equal As Strings is a builtin keyword, not a keyword in this library. $.code doesn't evaluate into your response since the builtin keyword doesn't know anything about your response object.

You can store the response into a variable and then evaluate if that is equal to your expected value, e.g

${code}=    Output    $.code
Should Be Equal As Strings    ${code}    40001

or you can use the String or Integer keywords directly to check whether the code is expected, e.g.

String    $.code    40001
asimell commented 2 years ago

Closing issue as there is no new information.