Failed to compare images with Imagemagick with rob

2019-03-06 18:38发布

I am using Imagemagick to compare two screenshots in windows environment.

https://blog.codecentric.de/en/2017/09/robot-framework-compare-images-screenshots/

   *** Settings ***
Library   String
Library   OperatingSystem

*** Variables ***
${IMAGE_COMPARATOR_COMMAND}   C:\\"Program Files"\\ImageMagick-7.0.7-Q16\\convert.exe


*** Test Cases ***
Image Comparison Ok
  Compare Images    C:/Users/user/imagecompare/Test/src/reference-screenshots/reference-1.png    C:/Users/user/imagecompare/Test/src/test-screenshots/test-1.png   0.1


Image Comparison NOk
  Compare Images    C:/Users/user/imagecompare/Test/src/reference-screenshots/reference-1.png    C:/Users/user/imagecompare/Test/src/test-screenshots/test-1.png   0.1

*** Keywords ***
Compare Images
   [Arguments]      ${Reference_Image_Path}    ${Test_Image_Path}    ${Allowed_Threshold}
   ${TEMP}=         Replace String     ${IMAGE_COMPARATOR_COMMAND}    __REFERENCE__     ${Reference_Image_Path}
   ${COMMAND}=      Replace String     ${TEMP}    __TEST__     ${Test_Image_Path}
   Log              Executing: ${COMMAND}
   ${RC}            ${OUTPUT}=     Run And Return Rc And Output     ${COMMAND}
   Log              Return Code: ${RC}
   Log              Return Output: ${OUTPUT}
   ${RESULT}        Evaluate    ${OUTPUT} < ${Allowed_Threshold}
   Should be True   ${RESULT}

But getting the following issue:

    KEYWORD BuiltIn . Log Return Output: ${OUTPUT}
Documentation:  
Logs the given message with the given level.
Start / End / Elapsed:  20171016 15:45:38.561 / 20171016 15:45:38.562 / 00:00:00.001
15:45:38.561    INFO    Return Output: The system cannot find the path specified.   
00:00:00.003KEYWORD ${RESULT} = BuiltIn . Evaluate ${OUTPUT} < ${Allowed_Threshold}
Documentation:  
Evaluates the given expression in Python and returns the results.
Start / End / Elapsed:  20171016 15:45:38.562 / 20171016 15:45:38.565 / 00:00:00.003
15:45:38.563    FAIL    Evaluating expression 'The system cannot find the path specified. < 0.1' failed: SyntaxError: invalid syntax (<string>, line 1)

1条回答
女痞
2楼-- · 2019-03-06 19:16

If you want to use the "legacy" convert command with ImageMagick v7, you need to click the option during installation of ImageMagick that says "Install legacy tools".

enter image description here

Or, use the new command which is:

magick input.png ... output.png

rather than:

convert input.png ... output.png

So, if you know how to change your configuration variable IMAGE_COMPARATOR_COMMAND to C:\\"Program File"\\ImageMagick-7.0.7-Q16\\magick, you can do it without re-installing ImageMagick.

查看更多
登录 后发表回答