robotframework - PO设计
1、添加新建好的资源
2、测试用例原始代码如下(未做任何分离的数据)
*** Settings ***
Library SeleniumLibrary
Resource UI分层一.txt
Resource UI分层二.txt
*** Test Cases ***
测试用例原始代码
Open Browser https://www.baidu.com firefox
Input Text id = kw selenium
Click Button id = su
Wait Until Page Contains Element css = #su
sleep 2
${title} get title
Should Contain ${title} selenium_百度搜索
Close Browser
3、调用 UI分层一
*** Settings ***
Library SeleniumLibrary
*** Keywords ***
打开浏览器
[Arguments] ${url} ${webdriver}
Open Browser ${url} ${webdriver}
输入框
[Arguments] ${search}
Input Text id = kw ${search}
点击百度搜索按钮
Click Button id = su
等待时间
sleep 2
验证标题
[Arguments] ${result}
${title} get title
Should Contain ${title} ${result}
关闭浏览器
Close Browser
4、调用 UI 分层二
*** Settings ***
Library SeleniumLibrary
Resource UI分层一.txt
*** Keywords ***
验证百度搜索
[Arguments] ${url} ${driver} ${input} ${text}
打开浏览器 ${url} ${driver}
输入框 ${input}
点击百度搜索按钮
等待时间
验证标题 ${text}
关闭浏览器