Search code examples
pythonseleniumvalidationrobotframeworkip-address

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!


Solution

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