Ниже приведен файл device_details.yaml, который мы используем для переменных,
Device1:
IP: 192.168.23.21
Port: 23
admin_cred:
username: admin
password: Cisco123$
nonadmin_cred:
username: six
password: six
Device2:
IP: 192.168.23.22
Port: 23
admin_cred:
username: admin
password: Cisco123$
nonadmin_cred:
username: six
password: six
Ниже приведен фрагмент кода робота:
*** Settings ***
Variables /tmp/robot/device_details.yaml
*** Test Case ***
Test
Device Detail
***Keywords****
Device Detail
Log Device1 IP is ${Device1.IP}
Log Device1 port is ${Device1.Port}
Log Device1 admin username is ${Device1.admin_cred.username}
Log Device1 admin password is ${Device1.admin_cred.password}
Log Device1 non-admin username is ${Device1.nonadmin_cred.username}
Log Device1 non-admin password is ${Device1.nonadmin_cred.password}
Log Device2 IP is ${Device2.IP}
Log Device2 port is ${Device2.Port}
Log Device2 admin username is ${Device2.admin_cred.username}
Log Device2 admin password is ${Device2.admin_cred.password}
Log Device2 non-admin username is ${Device2.nonadmin_cred.username}
Log Device2 non-admin password is ${Device2.nonadmin_cred.password}
В результате мы можем получить от 200 до 300 деталей устройства в файл yaml. Вместо вызова каждой переменной, есть ли способ динамически перебирать переменные один за другим?