简体   繁体   中英

Robot Framework: Create template

I have following code which open 2 browsers and closing at end. I want to make it as tempplate and reuse it. How to achieve it?

*** Test Cases ***
PhpTravels_Net
    : FOR    ${browser}    IN    @{listBrowser}
    \    Open Browser    https://planet2.swift.com/Pages/default.aspx    ${browser}
    \    Log    ${browser}
    Close All Browsers

Please help. Thanks.

This should do it. Note that I'm not using a list as you did, and set Close All Browsers to Teardown .

*** Settings ***
Library    SeleniumLibrary

*** Test Cases ***
PhpTravels_Net
    [Template]    Open Browser Template
    [Teardown]    Close All Browsers
    firefox
    chrome

*** Keywords ***
Open Browser Template
    [Arguments]    ${browser}
    Open Browser    https://planet2.swift.com/Pages/default.aspx    ${browser}
    Log    ${browser}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM