Charge With Token sale=${sale_uri} payment_token=${payment_token} sale_risk=${risk_uri}
# Charge With Token returns a list including http status codes as first element
Run Keyword If @{returned}[0] != 201 or @{returned}[0] != 400 Fail msg=Samething went wrong, please look at the log file
Documentation:
Runs the given keyword with the given arguments, if condition is true.
Start / End / Elapsed: 20160526 17:01:44.010 / 20160526 17:01:44.018 / 00:00:00.008
00:00:00.001KEYWORD BuiltIn . Fail Samething went wrong, please look at the log file
Documentation:
Fails the test with the given message and optionally alters its tags.
Start / End / Elapsed: 20160526 17:01:44.017 / 20160526 17:01:44.018 / 00:00:00.001
17:01:44.017 TRACE Arguments: [ 'Samething went wrong, please look at the log file' ]
17:01:44.018 FAIL Samething went wrong, please look at the log file
17:01:44.018 DEBUG Traceback (most recent call last):
None
17:01:44.011 TRACE Arguments: [ '400 != 201 or 400 != 400' | 'Fail' | 'Samething went wrong, please look at the log file' | 'ELSE' | 'Get Sale Info' | 'token=${sale_token}' ]
17:01:44.011 TRACE Arguments: [ '400 != 201 or 400 != 400' | 'Fail' | 'Samething went wrong, please look at the log file' | 'ELSE' | 'Get Sale Info' | 'token=${sale_token}' ]
@{returned}[0] != 201 or @{returned}[0] != 400
@{returned}[0] != 201 and @{returned}[0] != 400
Yes, the original expression can never be true. Another way to write it would be `@{returned}[0] not in [201, 400]`. Additionally, you could simply use Should Be True keyword instead of Run Keyword If in combination with Fail.
Sent from my mobile.
My assumption based on your logic of:
@{returned}[0] != 201 or @{returned}[0] != 400
Is that if the returned code is 400 or 201 you want it to not fail. The problem is in your logic:((400 does not equal 201) or (400 does not equal 400)) resolves as follows:
((True) or (False)) == (True) which executes the keyword Fail.I believe you want the logic to read with an and, such as:
@{returned}[0] != 201 and @{returned}[0] != 400
That way if the returned value is 201 or 400 the test will not execute the Fail keyword if the returned value is 201 or 400 but if the value is anything else the keyword executes.
On Thursday, May 26, 2016 at 10:41:57 AM UTC-5, Nesat Ufuk wrote:Hi robot folks,
I am trying to use Fail keyword to stop test case execution. But, I guess I am missing a part or something else.
Robot Code:
Charge With Token sale=${sale_uri} payment_token=${payment_token} sale_risk=${risk_uri}
# Charge With Token returns a list including http status codes as first element
Run Keyword If @{returned}[0] != 201 or @{returned}[0] != 400 Fail msg=Samething went wrong, please look at the log file
Herebelow is the trace:
Documentation:
Runs the given keyword with the given arguments, if condition is true.
Start / End / Elapsed: 20160526 17:01:44.010 / 20160526 17:01:44.018 / 00:00:00.008
00:00:00.001KEYWORD BuiltIn . Fail Samething went wrong, please look at the log file
Documentation:
Fails the test with the given message and optionally alters its tags.
Start / End / Elapsed: 20160526 17:01:44.017 / 20160526 17:01:44.018 / 00:00:00.001
17:01:44.017 TRACE Arguments: [ 'Samething went wrong, please look at the log file' ]
17:01:44.018 FAIL Samething went wrong, please look at the log file
17:01:44.018 DEBUG Traceback (most recent call last):
None
17:01:44.011 TRACE Arguments: [ '400 != 201 or 400 != 400' | 'Fail' | 'Samething went wrong, please look at the log file' | 'ELSE' | 'Get Sale Info' | 'token=${sale_token}' ]
Sincerely,
Nesat
--
You received this message because you are subscribed to the Google Groups "robotframework-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to robotframework-u...@googlegroups.com.
To post to this group, send email to robotframe...@googlegroups.com.
Visit this group at https://groups.google.com/group/robotframework-users.
For more options, visit https://groups.google.com/d/optout.