简体   繁体   中英

How to cross check multiple IP's using robot framework

How to cross check multiple IP's using robot framework:

Ex:

 ${Debug IP}=        192.168.101.103
 ${Gateway IP}=     191.168.104.102
 ${Subnet mask IP}=  132.145.128.101
 ${NEW IP}=          192.168.101.24

Here I created 4 variables as a input IP address and all are unique

If I Entered same IP address , need to show error

I wrote this command:

Should Not Match Regexp  | ${Debug IP} | ${Gateway IP} |  ${Subnet mask IP} | ${NEW IP}

But, it's apply for first 2 variables . it wont cross check with 3rd and 4th variable

Is there any othere way to validate

Thank you!

You can use Should Not Contain Any keyword from the builtin library. Below example should work

***Variables***
${Debug IP}          192.168.101.103
${Gateway IP}        191.168.104.102
${Subnet mask IP}    132.145.128.101
${NEW IP}            192.168.101.24
${unique_example}    1.1.1.1

*** Test Cases ***  
test 
    Should Not Contain Any    ${unique_example}    ${Debug IP}    ${Gateway IP}    ${Subnet mask IP}    ${NEW IP}
    Should Not Contain Any    ${Debug IP}    ${Debug IP}    ${Gateway IP}    ${Subnet mask IP}    ${NEW IP}

Using keyword List Should Not Contain Duplicates will help you out.

*** Settings ***

Library    Collections

*** Variables ***

${Debug IP} =          192.168.101.103
${Gateway IP} =        191.168.104.102
${Subnet mask IP} =    132.145.128.101
${New IP} =            192.168.101.24

*** Test Cases ***

IP addresses should be unique
    ${All IPs} =    Create List    ${Debug IP}    ${Gateway IP}    ${Subnet mask IP}    ${New IP}
    List Should Not Contain Duplicates    ${All IPs}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM