packagelocate prj不要为了工具而研究工具
要为业务而
就是这样我都不记得了
以前是怎么弄的
有空再来~~~
知道rfs也是要pom,道行不够,搁浅一阵子
先把手写的python接口搞定~~~
*** Settings ***
Library Selenium2Library
Library AutoItLibrary
Library DatabaseLibrary
Library HttpLibrary.HTTP
suit1
mysql
pip install --upgrade robotframework-httplibrary
向某IP和端口是9000发送一个请求,然后查看返回的状态,如果返回的状态有302,出现了重定向,请用Follow Response这个API继续,如果是200,那么就直接拿来使用。
Step3
Comment Start Step3
Create Http Context host=xx.xx.xx.xxx:9000 scheme=http
Get /xx/xxx/xxxx
${RESPONSE_STATUS}= Get Response Status
Should Start With ${RESPONSE_STATUS} 200
Comment End Step3
pip install pyodbc
suite1
*** Settings ***
Library Selenium2Library
Resource key11.txt
Library AutoItLibrary
Library HttpLibrary.HTTP
*** Test Cases ***
t1
[Documentation] destination:test1
...
...
... author:dido
打开baidu http://www.baidu.com
搜索内容 didododododo
[Teardown] run keyword if test failed close browser # teardown
retunkeyword
${a} set variable 4
${b} set variable 0
run keyword if ${a}>=1 log 1
... ELSE IF ${b}<=4 log 2 ElSE log
... 3
forxun
: FOR ${i} IN RANGE 3
\ log ${i}
\ 打开baidu http://www.badu.com
\ sleep 1
\ 关闭浏览器
evalue
${a} evaluate os.system(r'dir>d:\\text.txt') os
autoit
Run sublimetext3.exe
winwaitactive 记事本
send This is a test{1}^s
winwaitactive 另存为 *.txt
send {del}
odb
connect to database using custom params pyodbc "Driver={Mysql};Server=127.0.0.1;Database=test;UID='admin';PWD='test'"
${a} query select * from test.t1
log ${a}
disconnect from database
case3duocan
duokey1 111 222 333
Step3
Comment Start Step3
Create Http Context host=xx.xx.xx.xxx:9000 scheme=http
Get /xx/xxx/xxxx
${RESPONSE_STATUS}= Get Response Status
Should Start With ${RESPONSE_STATUS} 200
Comment End Step3
suite2
suite2
*** Settings ***
Library Selenium2Library
Resource key11.txt
*** Test Cases ***
testlog
log dido
mnav
openbrowser http://www.baidu.com/
set browser implicit wait 10
${title} set variable gettitle
inputtext id=kw hiloo dido
click element id=su
log ${title}
closebrowser
key1
${result} create list 糯米 新闻 hao123 地图 视频
... 贴吧 学术
打开baidu
: FOR ${a} IN RANGE 6
\ ${title} 打开链接 ${a}
\ log ${title}
\ log ${result[${a}]}
\ should contain ${title} ${result[${a}]}
close all browsers
kkk
${result} Create List 糯米 新闻 hao123 地图 视频
... 贴吧
打开baidu
: FOR ${a} IN RANGE 6
\ ${title} 打开链接 ${a}
\ log ${title}
\ log ${result[${a}]}
\ Should Contain ${title} ${result[${a}]}
close all browsers
testkey
打开baidu http://www.baidu.com
搜索内容 didododododo
fal
runkeywordif
should be true
should not be true
:for
exit for loop
exit for if
keyword
*** Settings ***
Library Selenium2Library
*** Keywords ***
打开baidu
[Arguments] ${url}
open browser ${url}
set browser implicit wait 10
打开链接
[Arguments] ${i}
${s} get webelements css=.mnav
click element ${s[${i}]}
sleep 3
${title} get title
log ${title}
go back
[Return] ${title}
登陆
搜索内容
[Arguments] ${stext}
inputtext id=kw ${stext}
关闭浏览器
close browser
duokey
[Arguments] ${arg1} ${arg3} ${arg4} ${arg2}=222
duokey1
[Arguments] ${arg4} @{arg2} # at is a list and should be last
Fail ${arg4}===${arg2}
p.s.
越是靠近上层的部分,脚本越贴近自然语言,或者说很像我们的测试案例;越靠近下层的部分,越是接近页面元素的代码级部分。这样以后如果发生维护的时候,根据需要维护的内容,只需要在很少的地方进行调整即可。比如一个元素的id变了,那我只要在elements里面更新就行了。比如测试的流程调整了,以前是ABC的页面顺序,现在是ACB的页面顺序,那么只要在testflow层进行调整即可。
那么回到我们的标题,流程与数据分离,实际上目前我们的流程都集中在testflow以及下面的部分,而数据一般都是在案例层去给流程层传递,这就是我们的流程与数据分离了。当然,我们还可以再进一步的分离,把数据放到外面,脱离我们的案例,在运行的时候才传递进行,也是可以实现的。
名称 | 浏览器 |
---|---|
firefox | FireFox |
ff | FireFox |
internetexplorer | Internet Explorer |
ie | Internet Explorer |
googlechrome | Google Chrome |
gc | Google Chrome |
chrome | Google Chrome |
opera | Opera |
phantomjs | PhantomJS |
htmlunit | HTMLUnit |
htmlunitwithjs | HTMLUnit with Javascipt support |
http://ratlsun.iteye.com/blog/1869379
名称 | 浏览器 |
---|---|
firefox | FireFox |
ff | FireFox |
internetexplorer | Internet Explorer |
ie | Internet Explorer |
googlechrome | Google Chrome |
gc | Google Chrome |
chrome | Google Chrome |
opera | Opera |
phantomjs | PhantomJS |
htmlunit | HTMLUnit |
htmlunitwithjs | HTMLUnit with Javascipt support |
网友评论