How can I choose to show only unequal data result and minus or blind equal data result?

南笙酒味 提交于 2019-12-11 19:16:06

问题


Here's my robot code

There are 22 records on both tables but only 1 record has an unequal data I would like to show that result and minus or blind an equal data result.

 connect to database using custom params  cx_Oracle    ${DB_CONNECT_STRING}
 @{queryResultsA}=   Query  Select count (*) from QA_USER.SealTest_Security_A order by SECURITY_ID
 Log  ${queryResultsA}
 @{queryResultsB}=   Query  Select count (*) from QA_USER.SealTest_Security_B order by SECURITY_ID
 Log  ${queryResultsB}

should not contain match    ${queryResultsB}  ${queryResultsA}

回答1:


  1. Using For Loop

     # Assuming your table has values like this
    @{queryResultsA}=   Create List     a   b   c   d   e
    @{queryResultsB}=   Create List     a   z   c   d   e
    
    ${Length}=  Get Length      ${queryResultsA}
    ${count}=   Set Variable
    
    :FOR     ${count}   IN RANGE     ${Length}      
    \       Run Keyword If  '@{queryResultsA}[${count}]'!='@{queryResultsB}[${count}]'      Log To Console      @{queryResultsA}[${count}] @{queryResultsB}[${count}]
    

    OUTPUT
    b z

  2. Using SET

    ${z} =  Evaluate    (set(${queryResultsA}) - set(${queryResultsB}))
    Log     ${z}
    

    OUTPUT
    b

    Note the difference here Set B is subtracted from Set A so whatever not matched in set A will be the output.



来源:https://stackoverflow.com/questions/54090508/how-can-i-choose-to-show-only-unequal-data-result-and-minus-or-blind-equal-data

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