robotframework 如何读取excel中循环入参

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

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值