Failed to compare images with Imagemagick with robot framework on Windows environment

允我心安 提交于 2019-12-02 16:59:49

问题


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:


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".

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.



来源:https://stackoverflow.com/questions/46773762/failed-to-compare-images-with-imagemagick-with-robot-framework-on-windows-enviro

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!