Robot framework 循环读取excel中入参
从本地文件读取用户名和密码实现多用户的登陆,详情见下。
[if !supportLists]① [endif]编写登陆操作,详情见下。
以上三个参数中地址取值公共参数,见下图。另外登录用户名和密码都是依据excel每行记录进行取值入参。
Excel文件中最好都设置为文本格式,在单元格左上角填入’。
循环读取excel入参如下,excel中有多少行就循环多少次,见下。
具体脚本如下。
*** Settings ***
Library Selenium2Library
Library DatabaseLibrary
Resource ./业务流程.txt
Library ExcelLibrary
Library Collections
*** Variables ***
${URL-pre} http://172.29.0.180/sncfc-smp/login/index.do # pre新进件菜单地址
${URL-sit} http://172.29.0.188:8015/sncfc-smp/login.jsp # sit新进件菜单地址
${username} 17010438 #操作用户名
${password} `123Qwer #操作用户密码
*** Test Cases ***
新进件申请-店内任性付
01打开浏览器并登录 ${URL-pre} ${username} ${password}
#打开菜单进入主页面
店内任性付测试1
00打开浏览器并登录 ${URL-pre}
#打开菜单进入主页面
00LOGIN
[Arguments] ${URL-pre} ${username} ${password}
[Timeout]
Open Browser ${URL-pre} chrome
Maximize Browser Window
Input Text id=username ${username}
Input Text id=password ${password}
click BUTTON id=button1
sleep 2
Confirm Action
wait until element is visible id=logout
close Browser
00打开浏览器并登录
[Arguments] ${URL-pre}
[Timeout]
open excel C://Python27//ExcelRobotTest//ExcelRobotTest.xls
@{list_column_A} get column values TestSheet1 0
#log many @{list_column_A}
${list_column_B} get column values TestSheet1 1
#log many ${list_column_B}
${count_row} get row count TestSheet1
#log many ${count_row}
set_suite_variable ${count_row}
${y} set_variable 1
: FOR ${x} IN RANGE ${count_row}
\ ${user0} set_variable ${list_column_A[${x}][${y}]}
\ log ${user0}
\ ${pwd0} set_variable ${list_column_B[${x}][${y}]}
\ log ${pwd0}
\ 00LOGIN ${URL-pre} ${list_column_A[${x}][${y}]} ${list_column_B[${x}][${y}]}
网友评论