python - 机器人框架: Create template

标签 python robotframework

我有以下代码,可以打开 2 个浏览器并在最后关闭。我想将其作为模板并重复使用。如何实现?

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

请帮忙。谢谢。

最佳答案

这应该可以做到。请注意,我没有像您那样使用列表,并将关闭所有浏览器设置为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}

关于python - 机器人框架: Create template,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58045441/

相关文章:

testing - Appium - 机器人框架 - 选择下拉

java - Mac OSX - IllegalStateException : The driver is not executable:

python - 如何按不可用的值过滤搜索

python - dash app : how position html div? 中的布局管理

python - 将列中的几个 0 替换为平均值 0 及其后续行

python - Pandas :使用 read_csv 解析不同列中的日期

python - 机器人框架 - "No keyword with name ' 运行进程'被发现”,同时包含进程库

Robotframework线程

Jenkins 构建挂起

python - 正则表达式提取多行散列注释