Home > Mobile >  How to cross check multiple IP's using robot framework
How to cross check multiple IP's using robot framework

Time:07-20

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!

CodePudding user response:

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}

CodePudding user response:

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}
  • Related